Question: Determine the processing time T ( n ) of the recursive algorithm: 1 int myTest ( int n ) { 2 if ( n <

Determine the processing time T(n) of the recursive algorithm:
1 int myTest( int n ){
2 if ( n <=0) return 0;
3 else {
4 int i = random( n -1);
5 return myTest( i )+ myTest( n -1- i );
6}
7}
providing the algorithm random( int n ) spends one time unit to return a random integer value uniformly distributed in the range [0, n] whereas all other instructions spend a negligibly small time (e.g., T (0)=0).
Hints: derive and solve the basic recurrence relating T(n) in average to T(n1),..., T(0). You might need the equation 1+1++1= n for deriving the explicit formula for T (n).

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!