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

Consider the pseudo code below 1a. Which recurrence relation best describes the

1a.

Which recurrence relation best describes the runtime of foo?

  1. T(N) = T(N-1) + O(1);

T(1) = O(1)

  1. T(N) = T(N/2) + O(1);

T(1) = O(1)

  1. T(N) = 2T(N/2) + O(1);

T(1) = O(1)

  1. T(N) = T(N/2) + O(N);

T(1) = O(1)

  1. None of the above

1b.

What is the run time?

  1. (N)
  2. (NlogN)
  3. (N^2)
  4. (N^2logN)
  5. 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!