It will run infinite times since condition i is always greater than -1. Please correct me if I am wrong.

# Why option D i s incorrect

**hungdzai**#5

Divide by two will never get you to negative value, that’s why solution D will run infinitely.

Let n=8;

- i=8 8 >- 1 true
- i=8/2=4 4 >- 1 true
- i=4/2=2 2 > -1 true
- i=2/2=0 0 > -1 true
- i=0/2=0 0 > -1 true
- i=0/2=0 0 > -1 true…

This loop continues and won’t terminate…

here :—

4. i=2/2 is 1 which is > -1 (true)

now 5. i=1/2 is 0 0>-1 true…

and then loop continues and won’t terminate…

The loop will run infinite no of times. As " i " will never become negative in this case.

**manab-sarkar**#10

let take a value for n suppose n=7,now then update operator(i/=2) occur each time its divide n by 2 so it becomes n=7(initially) ->3 ->1 ->0 it will never go below 0 and as we know 0>-1 so the condition satisfy always and it becomes an infinite loop.

Listen do a test for sample case where n=16;

if first for loop i=0 to i<16 // This loop will execute for 16 times // T.C O(N).

if second for loop i // This loop will execute for 8times // T.C O(N/2).

if third for loop // This loop will execute for 5 times // T.C O(logN).

if fourth for loop // This loop will execute for infinite times //