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”.
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
35 Uses162 Views4 Likes