I just thought that while loop is running log(n) times and the inner for loop is running n times. so nlogn. I must be wrong about this process then.

Dark Mode

628 views

0 votes

closed as a duplicate of:
GATE CSE 2023 | Question: 44

Time complexity

f( ) { while(n>1) { for (i = 1 to n) { } n = n/2 } } g ( ) { for (i = 1 to 100n) { } }

- $f(x)=O(g(x))$
- $f(x)=\theta(g(x))$
- $f(x)=o(g(x))$
- $f(x)=\omega(g(x))$

1