This question features some code for a search algorithm.
read the code an identify formal and actual parameters
explain variable scope and identify the scope of a variable
predict the values of a variable at a breakpoint, (by doing a trace)
There are additional notes at the end which are not part of the question but will help to develop your understanding.
local variables and scope of a variable, including code efficiency
choosing to use a function or a procedure
You can run and edit code in the replit project included on this page to explore the question and better understand the concepts
question introduction
CoasterRocks theme park is running an online competition to win a free family ticket. People visit the web page and enter their email.
After the closing date a program will sort the emails into order so that multiple entries from the same email can be identified. It will then create a list of unique emails from which to choose the winner.
The algorithm for this program is shown below.
Import the emails from the text file into the array called emails
Sort the emails array into ascending order
Store a list of unique emails in an array called uniques
Choose a random winner from the uniques array
The table below shows the contents of the emails and uniques arrays after steps 2 and 3.
emails array after step 2 | uniques array after step 3