Question: 3. Consider the implementation of an algorithm finding the largest element in the array. Show the best case and worst case running time of
3. Consider the implementation of an algorithm finding the largest element in the array. Show the best case and worst case running time of the following function. Explain your answer briefly. // 1 is the starting index here. function maximum_element (array[1 to N]) if N = 1 do // return array[1] else if array[1]> maximum_element (array[2 to N]) return array[1] else return maximum_element( array[2 to N])
Step by Step Solution
3.37 Rating (166 Votes )
There are 3 Steps involved in it
Best Case The best case occurs when the largest element is at the ... View full answer
Get step-by-step solutions from verified subject matter experts
