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
3
votes
1 answer

Fast data structure for random and sequential access

I'm looking for a data structure or a combination of various data structures that perform very well on random and sequential access. I need to map an (integer) id to a (double) value and sort by that value. The values can occur multiple times. The…
thertweck
  • 1,120
  • 8
  • 24
3
votes
2 answers

Find the computational complexity for the following loops

For n=1 : Inner loop will execute 1 time. For n=2 : Inner loop will execute 1+2 times. For n=4 : Inner loop will execute 1+2+4 times. For n=8 : Inner loop will execute 1+2+4+8 times. . . . So how can I find the computational complexity? My answer…
Ammar Alyousfi
  • 4,112
  • 5
  • 31
  • 42
3
votes
2 answers

Solving the recurrence T(n) = T(n/2) + T(n/4) + T(n/8)?

I'm trying to solve a recurrence T(n) = T(n/8) + T(n/2) + T(n/4). I thought it would be a good idea to first try a recurrence tree method, and then use that as my guess for substitution method. For the tree, since no work is being done at the…
DillPixel
  • 955
  • 1
  • 14
  • 20
3
votes
4 answers

Complexity for 2n^2 + n

If a problem of complexity 2n^2 + n can be solved in 24 units of time for n = 2, how long does it take for n = 4? I was told that the answer is 48. But I believe it should be 24^2 because the complexity of the algorithm is O(n^2). Appreciate if…
Paul Brown
  • 39
  • 3
3
votes
1 answer

time complexity of line segment or edge intersection finding algorithms

I briefly reviewed the literature on line intersection and line arrangement problems in computational geometry. Most of them are based on plane sweep algorithm. From the angle of computational complexity, it seeems to me that the asymptotic…
3
votes
4 answers

Interview questions

This is an interview question: Given: f(n) = O(n) g(n) = O(n²) find f(n) + g(n) and f(n)⋅g(n)? What would be the answer for this question?
nathan1138
  • 2,635
  • 2
  • 15
  • 15
3
votes
1 answer

Exponents in big-O notation

Is 3n = O(2n)? how about (3/2)n = O(2n)? Can you explain the answers? I got false for the first since, 3n grows faster then 2n no matter what constant C you multiply 2n by. And same for the second? How about log(3n) = O(log (2n) )? I think we can't…
Kalon
  • 111
  • 1
  • 10
3
votes
3 answers

Calculating complexity?

I've been trying to calculate the complexity of the following function: k=n; while(k>0) g(n); k=k/2; {Comment: this is integer division, so 1/2=0} end while; for(j=0;j
3
votes
1 answer

Assymptotic time complexity of this algorithm

I would like to know the time complexity of the following algorithm. At first glance the time complexity looks to be O(n^5) and that is what is mentioned in majority of the sites i have seen on the internet. But a careful analysis seems to give a…
sasidhar
  • 7,523
  • 15
  • 49
  • 75
3
votes
1 answer

Solving for Big Theta Notation

I'm having an issue solving for big theta notation. I understand that big O notation denotes the worst case and upperbound while Omega notation denotes the best case and lower bound. If I'm given an algorithm that runs in O(nlogn) time and…
user1364768
  • 2,213
  • 3
  • 16
  • 8
2
votes
1 answer

asymptotic time complexity of scheme functions

I am trying to teach myself scheme and the concept I am struggling with the most is space and time complexity. I was doing some of the exercises at the end of the chapter and I have not been able to figure out the following two. I am trying to…
2
votes
4 answers

Merge sort worst case running time for lexicographic sorting?

A list of n strings each of length n is sorted into lexicographic order using the merge sort algorithm. The worst case running time of this computation is? I got this question as a homework. I know merge sort sorts in O(nlogn) time. For…
user567879
  • 5,139
  • 20
  • 71
  • 105
2
votes
2 answers

The Recurrence T(n)= 2T(n/2) + (n-1)

I have this recurrence: T(n)= 2T(n/2) + (n-1) My try is as follow: the tree is like this: T(n) = 2T(n/2) + (n-1) T(n/2) = 2T(n/4) + ((n/2)-1) T(n/4) = 2T(n/8) + ((n/4)-1) ... the hight of the tree : (n/(2h))-1 = 1 ⇒ h = lg n - 1 = lg n - lg 2…
Sosy
  • 109
  • 1
  • 2
  • 12
2
votes
3 answers

Runtime of this pseudocode

Can anyone help me analyze the run time of the following pseudocode for(i = 0; i < n*n*n; i++) for(j = i; j < n; j++) x++ The way I see it's omega(n^3) for the lower bound, since that's what it would be if inside the outer for-loop was…
Andrew
  • 2,519
  • 6
  • 29
  • 46
2
votes
4 answers

Question about big O and big Omega

I think this is probably a beginner question about big-O notation. Say, for example, I have an algorithm that breaks apart an entire list recursively(O(n)) and then puts it back together (O(n)). I assume that this means that the efficiency is O(n) +…
A D
  • 789
  • 1
  • 12
  • 29