Question: .1.[4 marks]First, design a divide-and-conquer algorithm to find the position of the largest element in an unsorted array. Your algorithm should make exactly1comparisons between array
.1.[4 marks]First, design a divide-and-conquer algorithm to find the position of the largest element in an unsorted array. Your algorithm should make exactly1comparisons between array elements.
2.[6 marks]Now let us consider the problem of finding the second largest element of A using at mostn+dlog2ne1comparisons. Here is an outline of an algorithm that can achieve this:Start with your algorithm from part (a).Modify it, by recording some additional information each time a comparison is done.Finally, after finding the position of the largest element of A, use the recorded information to find its second-largest element using at mostdlog2neadditional comparisons
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
