Question: Given the following code fragment: for (int i = n; i > n; i=i/2) sum++; What would the big-o notation be? Please explain why

Given the following code fragment: for (int i = n; i > n; i=i/2) sum++; What would the big-o notation be?

Given the following code fragment: for (int i = n; i > n; i=i/2) sum++; What would the big-o notation be? Please explain why or how you got to that answer: i. O(log n) ii. O(n) iii. O(n/2) iv. O(2^n)

Step by Step Solution

3.46 Rating (162 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The detailed answer for the above question is provided below The provided code fragment contains a l... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Algorithms Questions!