Question: Modify the algorithm to solve the problem of finding the k-th largest number in array A, 1kn, without sorting the entire array. Partsof the algorithm
Modify the algorithm to solve the problem of finding the k-th largest number in array A, 1kn, without sorting the entire array. Partsof the algorithm are given below. Fill in the blanks.
Select-k-th-largest(A: Array [1..n] of numbers)
1 for _____________________
2 ________________
3 for _____________________
4 if _______________ then ___________
5 if position i then
6 temp=A[i]
7 A[i]=A[position]
8 A[position]=temp
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
