Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

ISRO | ISRO CS 2017 | Question 19

  • Last Updated : 15 Mar, 2018

Consider the program

void function(int n) {
int i, j, count=0;
for (i=n/2; i <= n; i++)
for (j = 1; j <= n; j = j*2)
count++;}

The complexity of the program is
(A) O(log n)
(B) O(n2)
(C) O(n2 log n)
(D) O(n log n)


Answer: (D)

Explanation: The outer loop runs n/2 times
The inner loop runs logn times
Therefore the total time complexity of the program is O(nlogn) which is option (D)

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :