Skip to content
Related Articles

Related Articles

Improve Article

GATE | GATE-CS-2004 | Question 83

  • Last Updated : 28 Jun, 2021

The time complexity of the following C function is (assume n > 0)

Attention reader! Don’t stop learning now.  Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.

Learn all GATE CS concepts with Free Live Classes on our youtube channel.




int recursive (int n) {
   if (n == 1)
      return (1);
   else
      return (recursive (n - 1) + recursive (n - 1));
}

(A) O(n)
(B) O(n log n)
(C) O(n2)
(D) O(2n)


Answer: (D)

Explanation:

anil_ds_83
See Question 4 of https://www.geeksforgeeks.org/data-structures-and-algorithms-set-4/

This solution is contributed by Anil Saikrishna Devarasetty


Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :