An algorithm that determines a parcel's shipping category based on its weight is shown below.
1 SET parcelWeight TO 12.5
2
3 IF (parcelWeight >= 20.0) THEN
4 SEND "Heavy" TO DISPLAY
5 END IF
6 IF (parcelWeight >= 10.0) AND (parcelWeight < 20.0) THEN
7 SEND "Medium" TO DISPLAY
8 END IF
9 IF (parcelWeight >= 5.0) AND (parcelWeight < 10.0) THEN
10 SEND "Light" TO DISPLAY
11 END IF
12 IF (parcelWeight < 5.0) THEN
13 SEND "Eco" TO DISPLAY
14 END IF
The use of multiple independent selection statements in this algorithm is inefficient.
Explain how the algorithm should be amended to address this inefficiency.
159 exam-style questions on Edexcel GCSE Computer Science Algorithms, covering Constructs for solving problems, Variables, constants and data structures, Arithmetic, relational and logical operators, Tracing algorithm output with trace tables, Types of error and correcting logic errors, Standard algorithms (sorts and searches), and Evaluating algorithm fitness and efficiency. Each one has a worked solution and a mark scheme showing where the marks go.