Question: You are given an algorithm to find the k maximum elements from a 2D array How the algorithm works: You create an array of size

 You are given an algorithm to find the k maximum elements

You are given an algorithm to find the k maximum elements from a 2D array How the algorithm works: You create an array of size k to track the players. You then find the maximum element in the array by traversing the whole array once. After finding the element, you add it to an array which keeps tracks of the players and initialize the score of the player to -1 so that it doesn't come up as maximum in further iterations. Repeat this k times to find the k maximum elements in the array T[] : T[k] where k is the number of players who have maximum score To find the k maximum scorer: for x0 to k maxScorer A[O[O] for i-0 to m for j-0 to n if maxScorer.score

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!