Hello Stack Users, I am having trouble finishing this growth according to size algorithm problem. I was able to figure out the first two of the problem which are not listed in the picture. That would be 1. O(1) and 3. O(N) I was able to place these into their correct slots. I still cannot figure out how to determine the growth rate for 2,4,5,6 into the slots provided. Any suggestions on how to determine this?
Asked
Active
Viewed 1,482 times
1 Answers
2
O(N)
The first for loop takes N and the second also takes N so
O(N) = N + N = 2N = N
O(N^2)The first for loop takesNand the second alsoN, but in this case it is nested. inner loop takesNfor every other loop of outer loopO(N) = N * N = O(N^2)
O(N)
The first for loop it takes N and the second also 5, but it is nested so
O(N) = 5 * N = 5N = O(N)
O(log(N))to divide a number
Nby2continuously until it reaches1, it takeslog(N)
The Scientific Method
- 2,374
- 2
- 14
- 25
-
-
I am sorry answers aren't reusable I should have stated that. Answer 1 and answer 3 are gone so there are only 4 options left to choose from from one for each problem. – hotrod28 Sep 09 '18 at 22:09
-
