GATE CS 2013 · Question 31 · Programming and Data Structures · Multiple choice (MCQ) · 2 marks · −2/3 for a wrong answer

Consider the following function:
int unknown(int n){ int i, j, k=0; for (i=n/2; i<=n; i++) for (j=2; j<=n; j=j*2) k = k + n/2; return (k); }
The return value of the function is

  1. (A) Θ(n²)
  2. (B) Θ(n² log n)
  3. (C) Θ(n³)
  4. (D) Θ(n³ log n)
Answer

Answer (B)

Answer from the official GATE CS 2013 answer key.

The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes