big-theta

How to get Omega(n)

无人久伴 提交于 2019-12-12 10:53:21
问题 I have the formula a(n) = n * a(n-1) +1 ; a(0) = 0 How can i get the Omega, Theta or O Notation from this without the Master Theorem or did anyone have a good site to understand the explanation 回答1: The Master theorem doesn't even apply, so not being able to use it isn't much of a restriction. An approach which works here is to guess upper and lower bounds, and then prove these guesses by induction if the guesses are good. a(0) = 0 a(1) = 1 a(2) = 3 a(3) = 10 a(4) = 41 A reasonable guess for

Algorithm asymptotic-complexity

我是研究僧i 提交于 2019-12-11 03:03:49
问题 I would like to know what is the minimum and maximum value this procedure can return in the following algorithm using the big-theta notation. The algorithm is: procedure F(𝐴[1..n]) s = 0 for i = 1 to n j = min(max(i,A[i]),n³) s = s + j return s 回答1: EDIT: removed original answer as it was for the wrong question. The analysis hinges on the following line: min(max(i,A[i]),n³) If we figure out the cases for this then we can easily figure the cases for the result. We must answer whether i > A[i]

Running Time of Randomized Binary Search

青春壹個敷衍的年華 提交于 2019-12-08 09:27:24
问题 Consider the following silly randomized variant of binary search. You are given a sorted array A of n integers and the integer v that you are searching for is chosen uniformly at random from A. Then, instead of comparing v with the value in the middle of the array, the randomized binary search variant chooses a random number r from 1 to n and it compares v with A[r]. Depending on whether v is larger or smaller, this process is repeated recursively on the left sub-array or the right sub-array,

Asymptotic analysis of three nested for loops

泄露秘密 提交于 2019-12-07 03:06:04
问题 I want to calculate the theta complexity of this nested for loop: for (int i = 0; i < n; i++) { for (int j = 0; j < i; j++) { for (int k = 0; k < j; k++) { // statement I'd say it's n^3, but I don't think this is correct, because each for loop does not go from 1 to n. I did some tests: n = 5 -> 10 10 -> 120 30 -> 4060 50 -> 19600 So it must be between n^2 and n^3. I tried the summation formula and such, but my results are way too high. Though of n^2 log(n), but that's also wrong... 回答1: It is

Example of algorithm which has different worst case upper bound, worst case lower bound and best case bounds?

落爺英雄遲暮 提交于 2019-12-06 12:38:53
问题 Is there any algorithm A, such that for a set of worst case instances S for A, A has different worst case upper bound and worst case lower bound? Moreover it should have different best case bounds not equal to any worst case bounds,for some set of inputs. For example say H is a hypothetical algorithm such that H has worst case upper bound Ο(n^3), worst case lower bound Ω(n^2) and best case running time Θ(n). Let me know that above situation is actually meaningful or not? Thanks :) 回答1: Here's

Confused on whether to express time complexity with theta notation or Big Oh notation

纵饮孤独 提交于 2019-12-06 10:20:46
How to decide on expressing time complexity of algorithm ? Should we choose to express time complexity in terms of O(n) or theta(n) ? Because a function f(n) can be expressed as either Big-Oh(g(n)) or theta (g(n)) . When do we choose big-oh over theta ? Use Big Theta notation when you want to also specify a lower bound. f(n) = O(g(n)) says that f is bounded above by g , whereas f(n) = Theta(g(n)) says that f is bounded both above and below by g . In other words, there are constants k1 and k2 such that k1 * |g(n)| <= |f(n)| <= k2 * |g(n)| 来源: https://stackoverflow.com/questions/5365724/confused

Asymptotic analysis of three nested for loops

时光总嘲笑我的痴心妄想 提交于 2019-12-05 07:50:16
I want to calculate the theta complexity of this nested for loop: for (int i = 0; i < n; i++) { for (int j = 0; j < i; j++) { for (int k = 0; k < j; k++) { // statement I'd say it's n^3, but I don't think this is correct, because each for loop does not go from 1 to n. I did some tests: n = 5 -> 10 10 -> 120 30 -> 4060 50 -> 19600 So it must be between n^2 and n^3. I tried the summation formula and such, but my results are way too high. Though of n^2 log(n), but that's also wrong... It is O(N^3) . The exact formula is (N*(N+1)*(N+2))/6 Using Sigma Notation is an efficient step by step

Example of algorithm which has different worst case upper bound, worst case lower bound and best case bounds?

放肆的年华 提交于 2019-12-04 19:19:39
Is there any algorithm A, such that for a set of worst case instances S for A, A has different worst case upper bound and worst case lower bound? Moreover it should have different best case bounds not equal to any worst case bounds,for some set of inputs. For example say H is a hypothetical algorithm such that H has worst case upper bound Ο(n^3), worst case lower bound Ω(n^2) and best case running time Θ(n). Let me know that above situation is actually meaningful or not? Thanks :) Here's a less natural but perhaps more satisfying definition of H . This function computes the cube of the sum of

Are 2^n and 4^n in the same Big-Θ complexity class?

◇◆丶佛笑我妖孽 提交于 2019-12-04 06:37:50
Is 2^n = Θ(4^n)? I'm pretty sure that 2^n is not in Ω(4^n) thus not in Θ(4^n), but my university tutor says it is. This confused me a lot and I couldn't find a clear answer per Google. chiwangc 2^n is NOT big-theta (Θ) of 4^n , this is because 2^n is NOT big-omega (Ω) of 4^n . By definition, we have f(x) = Θ(g(x)) if and only if f(x) = O(g(x)) and f(x) = Ω(g(x)) . Claim 2^n is not Ω(4^n) Proof Suppose 2^n = Ω(4^n) , then by definition of big-omega there exists constants c > 0 and n0 such that: 2^n ≥ c * 4^n for all n ≥ n0 By rearranging the inequality, we have: (1/2)^n ≥ c for all n ≥ n0 But

Big O and Big Omega are the same but in reverse?

我怕爱的太早我们不能终老 提交于 2019-12-02 16:50:19
问题 Is this true? f(n) = O(g(n)) === g(n) = Omega(f(n)) Basically are they interchangeable because they are opposites? So if F is in Big O of G, then G is Big Omega of F? 回答1: I've never particularly cared for the notation myself. The easiest way to think of this is that Big-O notation is the "worst case" and Big Omega is the "best case." There are, of course, other things you might be interested in. For example, you could state that the following (rather dumb) linear search algorithm is O(n),