Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions