Can you tell me why answer for question 1 is not option a?

i think n + n/2 + n/4 + … 1 = log n

@mb129162
Just to confirm, you are talking about this… right?

int count = 0;
for (int i = N; i > 0; i /= 2)
for (int j = 0; j < i; j++)
count++;

here the answer is the sum of this sequence --> n + n/2 + n/4 + … 1
it would have been logN if it there was no second loop.
because for every value of ‘i’ i.e. from n, n/2, n/4, … 1. j-loop will run the same number of times.

please explain ques no 6 also. Is this always true? i think log n is not multiple of n

@mb129162
for question no. 6 ans is O(N^2)
The code runs total no of times
= N + (N – 1) + (N – 2) + … 1 + 0
= N * (N + 1) / 2
= 1/2 * N^2 + 1/2 * N
O(N^2) times.

this is question no 6 ---->>> Frequently, the memory space required by an algorithm is a multiple of the size of input. State if the statement is True or False or Maybe.

@mb129162
for eg if you have to two numbers then we will take input in two variables so the Memory space required will be O(2), where the input size is 2. So its true