Skip to content

Course home

Algorithms

Algorithms

EasyMedium
123456789101112131415161718
Question 4

A developer is writing a shipping dispatch program to categorize packages based on their weight. She writes two different algorithms to achieve this, shown in Figure 1 and Figure 2.

Figure 1

1  SEND 'Enter package weight: ' TO DISPLAY
2  RECEIVE weight FROM (REAL) KEYBOARD
3  IF (weight < 5.0) THEN
4      SEND 'Standard courier' TO DISPLAY
5  ELSE
6      IF (weight <= 15.0) THEN
7          SEND 'Heavy courier' TO DISPLAY
8      ELSE
9          SEND 'Freight cargo' TO DISPLAY
10     END IF
11 END IF

Figure 2

1  SEND 'Enter package weight: ' TO DISPLAY
2  RECEIVE weight FROM (REAL) KEYBOARD
3  IF (weight < 5.0) THEN
4      SEND 'Standard courier' TO DISPLAY
5  END IF
6  IF (weight >= 5.0) AND (weight <= 15.0) THEN
7      SEND 'Heavy courier' TO DISPLAY
8  END IF
9  IF (weight > 15.0) THEN
10     SEND 'Freight cargo' TO DISPLAY
11 END IF

Explain why the algorithm in Figure 1 is more efficient than the algorithm in Figure 2.

[2]
Markscheme

Algorithms Questions

  1. IGCSE
  2. /Computer Science
  3. /Algorithms

45 exam-style questions on Edexcel IGCSE Computer Science Algorithms. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank