Efficiency of algorithms

EasyMedium
123456789
Question 6
Easy

An algorithm is required to multiply an input integer number by 5. Two different designs are proposed.

Figure 1

result ← number LEFTSHIFT 2
result ← result + number

Figure 2

result ← 0
FOR counter ← 1 TO 5
    result ← result + number
ENDFOR

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

[1]

Efficiency of algorithms Questions

  1. GCSE
  2. /Computer Science
  3. /Efficiency of algorithms