Asymptotic complexity is an approximation of the edge case performance of an algorithm used to determine best and worst case scenarios.
Questions tagged [asymptotic-complexity]
796 questions
4
votes
2 answers
What is the time complexity of the given algorthm?
x=0
for i=1 to ceiling(log(n))
for j=1 to i
for k=1 to 10
x=x+1
I've included the answer I've come up with here:
I think the time complexity is θ(n^2 log(n)), but I am not sure my logic is correct. I would really appreciate…

guest
- 43
- 5
4
votes
0 answers
Big O notation on some examples
The professor gave us a few examples to try at home but never gave us the answers and now when revising for the exams I would really like to go a bit more into detail with this. We have 3 "algorithms" and we have to work out the big O for these…

Elldorin
- 69
- 5
4
votes
1 answer
O(lg(n)) * O(lg(n)) in complexity theory
Stuck with some dumb question in complexity.
I have a loop that runs O(lg(n)) time. I have another loop inside that is also O(lg(n)) so the whole complexity is O(lg(n)) * O(lg(n)) or O(lg(n)2). Can I say that the final O is O(lg(n)) because since n…

Boltosaurus
- 2,138
- 3
- 21
- 33
4
votes
1 answer
Performance characteristics of ImmutableList
Is it somewhere documented the performance characteristics of ImmutableList? I'm interested in the asymptotic complexity (big-O). The msdn link doesn't reveal much.
I have known Add and this[] are both O(log n) from this article, but I want to…

nawfal
- 70,104
- 56
- 326
- 368
4
votes
2 answers
Constant amortized complexity for implementing a queue using two stacks
METHOD: Maintain two stacks A and B. Push into A. To pop look at B. If B is empty then pop A completely and push it into B and then pop from B. Otherwise simply pop from B.
QUESTION : 1)What is the difference between running time and amortized…

Dubby
- 1,154
- 3
- 16
- 31
4
votes
2 answers
Algorithm complexity, log^k n vs n log n
I am developing some algorithm with takes up O(log^3 n). (NOTE: Take O as Big Theta, though Big O would be fine too)
I am unsure whereas O(log^3 n), or even O(log^2 n), is considered to be more/less/equaly complex as O(n log n).
If I were to follow…
user1320847
4
votes
3 answers
Algorithm Analysis, Time Complexity of algorithm
m=1;
for(i=1;i<=n;i++){
m=m*2;
for(j=1;j<=m;j++){
do something that is O(1)
}
}
What will be time complexity of the above code ?? Please tell me how to solve these types of problem.

Ashok Naval
- 41
- 2
4
votes
5 answers
Algorithmic complexity of o(n)
I recently started playing with algorithms from this princeton course and I observed the following pattern
O(N)
double max = a[0];
for (int i = 1; i < N; i++)
if (a[i] > max) max = a[i];
O(N^2)
for (int i = 0; i < N; i++)
for (int j =…

tawheed
- 5,565
- 9
- 36
- 63
4
votes
3 answers
Running time(big O)) of an algorithm
i m calculating running time for this algorithm?
Cost No Of Times
for(j=1;j<=n-1;j++){ c1 n(loop will run for n-1 times +1 for failed cond
…

Ravi Bisla
- 405
- 1
- 4
- 10
4
votes
3 answers
complexity for nested loops
I am trying to figure out the complexity of a for loop using Big O notation. I have done this before in my other classes, but this one is more rigorous than the others because it is on the actual algorithm. The code is as follows:
for(i=n ; i>1 ;…

Hassan Bendouj
- 311
- 1
- 8
- 14
4
votes
3 answers
Running time of counting sort
I am trying to understand the running time of counting sort. In my notes, it says, assuming the size of the array A is n, and k is the number of times each number occurs,
Counting-Sort(A,k) {
for (i=1; i <= k; i++) // initialize number counters…
user2110714
4
votes
4 answers
Can not figure out complexity of this recurrence
I am refreshing on Master Theorem a bit and I am trying to figure out the running time of an algorithm that solves a problem of size n by recursively solving 2 subproblems of size n-1 and combine solutions in constant time.
So the formula is:
T(N) =…

Cratylus
- 52,998
- 69
- 209
- 339
4
votes
1 answer
Algorithm for generating all numbers that sum to a given number and its complexity
I found the following problem when preparing for an interview:
3 can be written as 1+1+1, 1+2, 2+1; 4 can be written as 1+1+1+1, 1+1+2, 2+2, 1+2+1, 2+1+1, 3+1, 1+3; Given an integer, how many possible expressions exist? (1+2 and 2+1 are…

user1923825
- 43
- 3
3
votes
3 answers
If f(n) = o(g(n)) , then is 2^(f(n)) = o(2^(g(n)))?
Notice that I am asking for little-o here (see similar question here) - for big Oh it's clearly wrong - for little-o it feels right but can't seem to prove it...
EDIT: glad I raised a debate :) Assume f,g > 0 for simplicity

Mr_and_Mrs_D
- 32,208
- 39
- 178
- 361
3
votes
1 answer
Meaning of a big O in an exponent
What does this expression f(n) = 2O(n) mean, in an exact formal manner?

Anatoly Libman
- 271
- 2
- 12