Question: Once upon a time, in a picturesque town, a highly competitive examination was held, with substantial rewards to the victors. It attracted huge numbers

Once upon a time, in a picturesque town, a highly competitive examination was held, with substantial rewards (a) To check if his algorithm works, Bob tried a toy example: the scores S = [66, 95, 13, 7, 14], and the

Once upon a time, in a picturesque town, a highly competitive examination was held, with substantial rewards to the victors. It attracted huge numbers of people to join from all over the world. As one of the participants in the competition, Bob was eager to find out his result. However, the only information Bob has is his rank and a list of the (anonymous) student scores that are stored in an array S. He designed the algorithms below to find his score from his ranking. Algorithm 1 findMyScore 1: Input: S = [81,82,81]: a list of student scores; l: the length of the list; re {ala N*,ze [1,1]}: the rank. 2: Initialization: i 1. 3: if 1 = 1 then score 5: else if l = 2 then 6: 7: 8: 9: 10: else 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: if S[1] > S[2] then 7: 8: 9: 10: S[1], S[2] = S(2], S[1] // sort array end if score S[r] // find the score as the r-th element in the sorted array S[r] // base case, if there is only one element in the array, the score is that element. while i l do pivot = S[i] rank, Sget Rank (S, 1, pivot) if rank 1/3 and rank

Step by Step Solution

3.35 Rating (161 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a In order to get Bobs score Algorithm 1 processes the input as follows Nondecreasing orderly sortin... View full answer

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 Programming Questions!