Question: Consider the pseudo code below 1a. Which recurrence relation best describes the runtime of foo? T(N) = T(N-1) + O(1); T(1) = O(1) T(N) =
Consider the pseudo code below

1a.
Which recurrence relation best describes the runtime of foo?
- T(N) = T(N-1) + O(1);
T(1) = O(1)
- T(N) = T(N/2) + O(1);
T(1) = O(1)
- T(N) = 2T(N/2) + O(1);
T(1) = O(1)
- T(N) = T(N/2) + O(N);
T(1) = O(1)
- None of the above
1b.
What is the run time?
- (N)
- (NlogN)
- (N^2)
- (N^2logN)
- None of the above
foo(b : int, N : int): if(N = 1) return b num foo(b, floor(N/2)) if(N mod 2 = 0) return num * num else return b * num num *
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
