Consider the recursive functions below which output the same value:
1 2 3 4 5 6 7 8 9 10 |
|
What is the running time of the algorithms?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
rec1 has linear descent to n=1. rec2 bifurcates at each level of descent to n=1. ( ∑ i = 0 n − 1 2 i ) + 1 for the original call gives 2 n .