GATE | GATE-CS-2004 | Question 83

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

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


(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
Article Tags :

1


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.