Analyze theta relation between sum of sqrt(i) and n*sq-root(n) - asymptotic-complexity

i want try to prove that:
sum of i^1/2 with i = 1 to n
and
n^3/2
are equal as asymptotic.
How can I prove this relation?

Related

Give an example of a sequence of n integers withΩ(n 2 ) inversions

I'm working on a exercise but it's confusing to understand.
I assume that the worst case for a inversion is that there is a sequence that's sorted in descending order: [n,n-1,...,0] which has (n(n-1))/2 inversions. Then we have to prove that (n(n-1))/2 >= C · n^2 based on the definition of omega which is g(n) >= C · f(n). But when n goes to infinity, g(n) = 1/2, so there doesn't exist a constant C which C>=1 and n0 >= 1 that satisfy the inequality.
What am I missing?
I'm assuming that the question you are asked is, Give an example of a sequence of n integers with Ω(n^2) inversions.
They worded this a bit sloppily. But here is what you need to come up with:
The rule for generating sequences.
A number 0 < n_0.
A constant 0 < C such that if n_0 < n then the number of inversions of the nth sequence is greater than C * n^2.
You've already given a rule that you think might work. n numbers sorted descending.
I would suggest that you try n_0 = 2 and C = 1/4.
Can you prove this statement?
If 2 < n, the descending sequence of length n has more than (1/4) * n^2 inversions.

time complexity of following recurrence relation?

I have a recurrence relation as following :
T (n) = n * T (n/b) + f (n)
then, how to find it's time complexity?
Can i compare 'a' with n in this relation?
How can i use Masters theorem in this recurrence relation?
Can i assume 'a' as n ,if so it gives 'b' = n and it becomes a = b = n ? is that all right ? T (n) becomes constant as a result. is that possible?

How to set up a recurrence relation for a given algorithm or program

How to set up a recurrence relation for a given algorithm or program?
For example we want to set up recurrence relation for this algorithm:
if n = 1
then return 1
else return Q(n-1) + n * n * n
See the link:
cs.uni.edu/~wallingf/teaching/cs3530/sessions/session07.html
On this page we have this algorithm:
if n = 1 then return 1
else return Q(n-1) + n * n * n
They said We set up a recurrence relation for the number of multiplications as:
M(1) = 0 M(n) = M(n-1) + 2
what's that mean ?
This already IS a recurrencr equation.
Written mathematically:
Q(n) = Q(n-1)+n^3
n0=1
Actually, anything that is evaluated using the value(s) calculated beforehand from the same function is termed as recurrence and this relation is recurrence relation.
So, the algorithm that you mention is the recurrence relation in itself, as it uses the value of Q(n-1), to evaluate Q(n).
However we manipulate a value to get the next (or desired) value, is the recurrence relation. A few examples of recurrences can be:
Fibonacci series:
F(0)=0, F(1)=1,
F(n) = F(n-1) + F(n-2)
Factorial:
F(0)=1,
F(n) = n * F(n-1)
etc.
So, here we need to find the recurrence of number of multiply operations that will be performed in evaluation of Q(n)
Since Q(1) = 1, and we know Q(1) directly, there is no multiply operation involved. So,
M(0) = 0
Any subsequent evaluation of Q involves 2 multiply operations:
Q(n) = Q(n-1) + n*n*n
So, there is one + operation and 2 * operations. So, we can write:
M(n) = M(n-1) + 2
So, complete recurrence will be:
M(0) = 0 (base case)
M(n) = M(n-1) + 2 (recurrence)
Actually, if you look clearly, there is no need of establishing a recurrence relation as number of * operations can be given directly by:
M(n) = 2*n,
And, this is not a recurrence relation, as it is not evaluated using previous values of the series.

Discrete Mathematics Big-O notation Algorithm Complexity

I can probably figure out part b if you can help me do part a. I've been looking at this and similar problems all day, and I'm just having problems grasping what to do with nested loops. For the first loop there are n iterations, for the second there are n-1, and for the third there are n-1.. Am I thinking about this correctly?
Consider the following algorithm,
which takes as input a sequence of n integers a1, a2, ..., an
and produces as output a matrix M = {mij}
where mij is the minimum term
in the sequence of integers ai, a + 1, ..., aj for j >= i and mij = 0 otherwise.
initialize M so that mij = ai if j >= i and mij = 0
for i:=1 to n do
for j:=i+1 to n do
for k:=i+1 to j do
m[i][j] := min(m[i][j], a[k])
end
end
end
return M = {m[i][j]}
(a) Show that this algorithm uses Big-O(n^3) comparisons to compute the matrix M.
(b) Show that this algorithm uses Big-Omega(n^3) comparisons to compute the matrix M.
Using this face and part (a), conclude that the algorithm uses Big-theta(n^3) comparisons.
In part A, you need to find an upper bound for the number of min ops.
In order to do so, it is clear that the above algorithm has less min ops then the following:
for i=1 to n
for j=1 to n //bigger range then your algorithm
for k=1 to n //bigger range then your algorithm
(something with min)
The above has exactly n^3 min ops - thus in your algorithm, there are less then n^3 min ops.
From this we can conclude: #minOps <= 1 * n^3 (for each n > 10, where 10 is arbitrary).
By definition of Big-O, this means the algorithm is O(n^3)
You said you can figure B alone, so I'll let you try it :)
hint: the middle loop has more iterations then for j=i+1 to n/2
For each iteration of outer loop inner two nested loop would give n^2 complexity if i == n. Outer loop will run for i = 1 to n. So total complexity would be a series like: 1^2 + 2^2 + 3^2 + 4^2 + ... ... ... + n^2. This summation value is n(n+1)(2n+1)/6. Ignoring lower order terms of this summation term ultimately the order would be O(n^3)

time complexity

Hi
I have a question that:
consider I have T(n) = m * n^2 (n<m)
is this correct to write T(n) = O(m) ? because I have written T(n) = m*n*n So because n<m we have T(n) = O(m)
thanks
No, the best thing you can do is to write T(n,m) = O(m^3). n < m is a very weak condition and basically just gives you n in O(m). For example, n could always be m-1.
Edit: My first answer was imprecise, as T was only a function in n. If m is constant, the answer is still holds, but O(m^3) is equal to O(1).
I believe in this case T(n) = O(n^2)
The formal definition of big-O:
f(x) = O(g(x)) if and only if there exists a positive real number M and a real number x0 such that |f(x)| ≤ M|g(x)| for all x > x0.
In your case, T(n) will always be less than or equal to m(n^2).

Resources