GATE CS Applied Course

ALGORITHM


0

The time complexity of the following C function is (assume n > 0) int recursive (mt n) { if (n == 1) return (1); else return (recursive (n-1) + recursive (n-1)); }

Answers

0

Vasudhan varma Posted on Aug 01, 2020 09:19 AM

it is same as T(n)=T(n-1)+T(n-1)+c =2T(n-1)+c From shortcut , method T(n)=aT(n-b)+n^k and a>1 is a^n/b so here it is a=2,b=1 T(n)= 2^n

© 2020 - All rights are reserved- AAIC Technologies pvt ltd