Question: Consider the following algorithm: 1 . def mystery _ algorithm ( n ) : 2 . result = 0 3 . i = 1 4

Consider the following algorithm:
1. def mystery_algorithm(n):
2. result =0
3. i =1
4. while i < n:
5. j = i
6. while j < n:
7. result +=1
8. j *=2
9. i +=1
10. return result
Prove the overall time complexity of the mystery_algorithm function in Big-O notation.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Programming Questions!