The leisure centre organises a squash competition - Edexcel - GCSE Computer Science - Question 5 - 2021 - Paper 1
Question 5
The leisure centre organises a squash competition. Players are ranked in descending order of the points they have scored in matches.
The rankings are set after each... show full transcript
Worked Solution & Example Answer:The leisure centre organises a squash competition - Edexcel - GCSE Computer Science - Question 5 - 2021 - Paper 1
Step 1
The algorithm includes an error on line 9. Name this type of error.
96%
114 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
The error on line 9 is a logic error. The comparison operator used does not appropriately check the indices of the array.
Step 2
Give a new line of code that will correct the error.
99%
104 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Replace line 9 with: IF index < LENGTH(arrayToSort) - 1 THEN.
Step 3
State the type of data structure referred to in the algorithm.
96%
101 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
The data structure referred to in the algorithm is a 2D array, specifically an array of records, where each record corresponds to a player containing their membership ID, name, and points.
Step 4
Describe how the algorithm could be refined to make it more efficient.
98%
120 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
To refine the algorithm for improved efficiency, the outer loop could continue until all players are sorted properly by utilizing a flag variable to track whether any swaps have occurred during the inner loop. If no swaps are made in a pass, the algorithm could terminate early. This minimizes unnecessary iterations.
Step 5
State two changes that could be made to the algorithm to improve the readability of the pseudocode.
97%
117 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Use comments to describe the purpose of each section of the code, clarifying the logic behind the sorting process.
Introduce whitespace between different control structures and logical blocks to enhance visual separation and readability of the pseudocode.