Question: 1. Consider the following pseudo code Algorithm: recursive Max( A, n) Input: array A of size n>-1 Output: maximum element of array A if T(n)
1. Consider the following pseudo code Algorithm: recursive Max( A, n) Input: array A of size n>-1 Output: maximum element of array A if T(n) is the run time of this code, then if n=1 T(n)- If( n=1 ) then T(n-1) +2 if n>1 return Alo] else time to execute Max(A,n-1) time for 2 comparison n=1? and max(a,b) return max(Max (A, n-1), A[n-1]) NOTE max( a,b) returns the maximum of a and b and you can find it in calgorithm> library Find the run-time of T(n)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
