Home Modern Forums ISRO

Consider the following segment of C-code:

int j, n;j = 1;while (j <= n) j = j * 2;

The number of comparisons made in the execution of the loop for any n > 0 is:
(A) |_ log 2n _| * n
(B) n
(C) |_ log2n _|
(D) |_ log2n _| + 1

Reply To:

Consider the following segment of C-code:

int j, n;j = 1;while (j <= n) j = j * 2;

The number of comparisons made in the execution of the loop for any n > 0 is:
(A) |_ log 2n _| * n
(B) n
(C) |_ log2n _|
(D) |_ log2n _| + 1

Up
0
Down
::

nan