Skip to content
Related Articles

Related Articles

ISRO | ISRO CS 2017 | Question 19

Improve Article
Save Article
  • Last Updated : 15 Mar, 2018
Improve Article
Save Article

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)

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
Related Articles

Start Your Coding Journey Now!