I am running Big O but totally lost.
while loop only run N/2 and for loop is also N/2 so it becomes N**2?
Am I thinking correctly?
# Block (a)
sum = 0;
n = N
while n > 0:
for i in range(0, n):
sum += 1;
n = n // 2
# running times: N/2 * N/2 = N^2/4 >> N^2?
# Block (b)
sum = 0
i = 1
while i < N:
for j in range(0, i):
sum += 1
i = i * 2
# running times: N^2??
# Block (c)
sum = 0
i = 1
while i < N:
for j in range(0, N):
sum += 1
i = i * 2
# running times: N^2??