At the moment marathon runners cross the finishing line of a race, their names are added to a stack called RUNNERS.
For example, a diagram of RUNNERS below indicates “Ellie” has finished first and “Jessie” last. “Jessie” is at the top of the RUNNERS stack.
Using pseudocode, construct an efficient procedure that will search the stack RUNNERS for a name given via standard input. Once the given name is found, output the finishing place of the runner specified as a number. If a name is not found then the procedure should output the message "Runner not found". Assume all names are unique, the number of elements in RUNNERS is unknown and RUNNERS may be emptied during the search process.
For example, given an input string of "Joel" the procedure will output the number 2 to indicate Joel finished in 2nd place.
Outline why the use of a queue would make this algorithm simpler and more efficient than using a stack.
In the same way as RUNNERS saves each runner's name, another stack called TIMES saves each runner's finishing time as they cross the finish line.
The results of a particular competition where 101 runners successfully finish a race are held in RUNNERS and TIMES. Given an empty 101x2 (row x column) 2D array called RESULTS, write pseudocode such that the first column contains the names of all those runners who finished the race and the second column contains their respective times in ascending rank order.
For example, RESULTS should contain the time of the runner who finished in 94th place, that is, having only ran faster than seven people (eighth last).
Using RESULTS, state the single line of pseudocode that represents the name of the runner with the median finishing time.
Extended Response12 MarksPremium
61 Uses117 Views3 Likes