ExamBank Scot · Higher Computing Science question bank · All Higher Computing Science questions

Higher Computing Science 2019 Question 18

10 marks · Sub-programs, parameters and scope

Identify from the code shown above a formal parameter an actual parameter. Explain what is meant by the scope of a variable. State the scope of the variable emails. The data below is used to test the program. emails array allan@giggle.com bert@yeeha.com bert@yeeha.com bert@yeeha.com colin@iclood.com colin@iclood.com … A breakpoint has been set at Line 77. The variables in the table below are inspected. Complete the table to show the values stored. Variable Value position newList[position] list[index] Explain the operation of lines 74 to 76 during the first iteration of the loop. The theme park is aware that their website might be subjected to a DOS attack. State the effect on customers of a DOS attack. CoasterRocks theme park is running an online competition to win a free family ticket. People visit the web page and enter their email. One lucky person will win a free family ticket worth £200. Just enter your email address in the box provided and click Submit. Confirm email: Submit Only one entry per person is permitted. Any further entries from the same email address will be removed. 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. 1. Imports the emails from the text file into the array called emails 2. Sorts the emails array into ascending order 3. Stores a list of unique emails in an array called uniques 4. Chooses 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 allan@giggle.com bert@yeeha.com bert@yeeha.com bert@yeeha.com colin@iclood.com colin@iclood.com ……………………….. allan@giggle.com bert@yeeha.com colin@iclood.com ……………………….. ……………………….. ……………………….. ……………………….. Part of the program code is shown below. Line 1 DECLARE emails AS ARRAY OF STRING INITIALLY [] Line 2 DECLARE uniques AS ARRAY OF STRING INITIALLY [] … Line 11 importEmails(emails) Line 12 sortEmails(emails) Line 13 removeDuplicates(emails, uniques) Line 14 chooseWinner(uniques) … Line 70 PROCEDURE removeDuplicates(ARRAY OF STRING list, ARRAY of STRING newList) Line 71 DECLARE position INITIALLY 0 Line 72 SET newList[position] TO list[0] Line 73 FOR index FROM 1 to length(list)-1 DO Line 74 IF list[index] ≠ newList[position] THEN Line 75 SET position TO position + 1 Line 76 SET newList[position] TO list[index] Line 77 END IF Line 78 END FOR Line 79 END PROCEDURE

Marking scheme

List or newList Emails or uniques Section of code in which a variable is accessible/usable Global or a description of global Lines 1 to 79 Variable Value position 1 newList[posi tion] bert@yeeha. com list[index] bert@yeeha. com 1 mark for each row Award 2 marks for: position 2 newList[position]: colin@iclood.com list[index]: colin@iclood.com Award 1 mark for: position 0 newList[position]: allan@giggle.com • bert@yeeha.com or list(1) does not equal allan@giggle.com or newlist(0) therefore condition is true • newList(1) is assigned the value bert@yeeha.com (list(1)) 1 mark for each bullet Accept answers that compare values from trace table in (c)(i) Award 1 mark for meaningful description that does not reference given values in the array • Slow performance • Inability to access 1 mark for each bullet Maximum 1 mark

Previous question: Higher Computing Science 2019 Question 17

Next question: Higher Computing Science 2021 Question 1