Questions tagged [asymptotic-complexity]

Asymptotic complexity is an approximation of the edge case performance of an algorithm used to determine best and worst case scenarios.

796 questions
2
votes
3 answers

Top K smallest selection algorithm - O (n + k log n) vs O (n log k) for k << N

I'm asking this in regards to Top K algorithm. I'd think that O(n + k log n) should be faster, because well.. for instance if you try plugging in k = 300 and n = 100000000 for example, we can see that O(n + k log n) is smaller. However when I do a…
ryaner
  • 3,927
  • 4
  • 20
  • 23
2
votes
3 answers

Big Oh notation (how to write a sentence)

I had a test about asymptotic notations and there was a question: Consider the following: O(o(f(n)) = o(f(n)) Write in words the meaning of the statement, using conventions from asymptotic notation. Is the statement true or false? Justify. I got…
Greg
  • 21
  • 1
2
votes
4 answers

efficiency of the closest pair algorithm

In T(n) = 2T(n/2) + M(n), where does the 2 in front of T come from. n/2 because it is dividing, and M(n) is linear, but I can't figure out what the 2 is for?
Aaron
  • 95
  • 1
  • 3
2
votes
1 answer

This algorithm's complexity is correct?

The algorithm I do not understand is : alg(m, n) 1. if m>n then 2. return alg(m-n, n) 3. else 4. if n>m then 5. return alg(n, m) 6. else 7. return n I think that the recurrence formula is T(m) = T(m-n) + a, where a is…
Cata
  • 39
  • 7
2
votes
1 answer

Finding the right complexity classes for functions

I am trying to find the right complexity classes for these functions: What I have so far is this. I will start from top to bottom: Is this correct?
Nime
  • 173
  • 1
  • 14
2
votes
3 answers

Asymptotic analysis question: sum[log(i)*i^3, {i, n}] is big-theta (log(n)*n^4)

I've got a homework question that's been puzzling me. It asks that you prove that the function Sum[log(i)*i^3, {i, n}) (ie. the sum of log(i)*i^3 from i=1 to n) is big-theta (log(n)*n^4). I know that Sum[i^3, {i, n}] is ( (n(n+1))/2 )^2 and that…
cjm
  • 3,703
  • 1
  • 16
  • 18
2
votes
1 answer

Comparing functions asymptotically

I am given two functions: F1(n)=2n+20 and F2(n)=n+1. I have to show which one is better. Our lecturer solved a similar problem. Given F1(n)=n2 and F2(n)=2n+20, he did: F2(n)/F1(n)=(2/n)+(20/n2) and he said it would be always less than 22, hence…
2
votes
1 answer

Asymptotic Analysis compare f and g

I have to compare the function f and g to find whether: f ∈ Θ(g), f ∈ O(g), f ∈ o(g), f ∈ Ω(g), f ∈ ω(g), g ∈ Θ(f), g ∈ O(f), g ∈ o(f), g ∈ Ω(f), g ∈ ω(f). f(n) = n^2/ log n and g(n) = n log n. As my understanding for the asymptotic analysis I…
Dan
  • 139
  • 1
  • 8
2
votes
2 answers

Time complexity of naïve merge of two binary search trees

I saw a very short algorithm for merging two binary search trees. I was surprised how easy and also very inefficient it is. But when I tried to guess its time complexity, I failed. Lets have a two immutable binary search trees (not balanced) that…
2
votes
1 answer

Big O notation of this function

function A(n): if n ≤ 10 then return 1 fi; x := 0; for i = 1 to n do x := x + 1 od; return x * A(n/3) * A(n/6) * A(n/4) My first idea was, that every call of A(n/c) is in O(log n) and since each has a for-loop from 1…
dYTe
  • 191
  • 1
  • 8
2
votes
1 answer

What is the difference between Work, Span and Time in parallel algorithm analysis?

When analysing parallel algorithms, we tend to focus Work(T1), Span(T∞) or time. What I'm confused about is that if I was given an algorithm to analyse, what key hints would I need to look for, for Work, span and time? Suppose this algorithm: How…
2
votes
2 answers

How to determine if a function is of a specific asymptotic type in algorithm analysis?

I'd like to have a better understanding of the asymptotic notation and how can one classify whether a function is of O notation of another function, and how can we tell whether f = o(g) || f != o(g) For example: For example, how can we tell that…
2
votes
2 answers

Asymptotic notation properties proofs?

I am trying to prove that if f(n) and g(n) are asymptotically positive functions, then: f(n) = O((f(n))^2) f(n) = O(g(n)) implies 2^(f(n)) = O(2^(g(n))) f(n) = O(g(n)) implies g(n) = O(f(n))
2
votes
1 answer

How would you n where one algorithm is preferred over another algorithm

I'm trying to compare two algorithms and their Big Oh efficiencies. I am trying to find the value for n where one algorithm becomes more efficient than the other algorithm. Any helpful examples or resources would be a huge help.
2
votes
1 answer

Asymptotic time complexity

after reading many articles or answers I still can't solve a problem of determining the asymptotic time complexity o a function. The function is for example like this: def function(n): for i in range(n): if i == 0: for j in…
Denyk
  • 99
  • 2
  • 7