math - Recurrence relation for basic operation -


i need little creating recurrence relation basic operation following recursive algorithm:

int d(int n) {   if (n==0) {     return 0;   }   return d(n - 1) + d(n - 1); } 

i think basic operation addition having trouble setting recurrence relation

are sure correct code? recurrence relation is

d(n) = 2 * d(n-1) base case d(n) = 0 

do see how works? function's recursion step shows recurrence step; function's termination clause shows base case.

i'm worried because in closed form, is

d(n) = 0 n 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -