Solution: Nested Loop with Multiplication (Pro)
Explore how to determine the time complexity of a nested loop where the inner loop doubles its iterator. Understand the use of logarithmic analysis and how to simplify expressions to Big O notation to evaluate algorithm efficiency.
We'll cover the following...
We'll cover the following...
Solution
The outer loop in the main function has n iterations as it iterates on i from 0 to n-1. If the condition j < i is true, the inner loop is entered. However, immediately, j is doubled. Note that j is not reset to 1 in the code since the j is immediately doubled, therefore inner while loop will run ...