Given an array containing 7 names called NAMES, the following algorithm outputs the first name found starting with “M”. It uses a utility function called firstLetter to return the first letter of a string - for example, firstLetter(“Kate”) will return the letter “K”.
[1]
N = 7 FIRST = “” FOUND = false i = 0 loop while i < N VALUE = NAMES[i] if firstLetter(VALUE) = "M" AND FOUND = false then FIRST = VALUE FOUND = true end if i = i + 1 end loop output FIRST
While the above algorithm functions as intended, suggest a suitable pseudocode modification to improve efficiency.

Short Answer1 MarkCommunity
22 Uses77 Views3 Likes
Login or Create an Account to view the mark scheme and add to a test