GRADE 9 · A4 PRINT VIEW
The World of Algorithms · Answer guide
Use your browser Print command and select A4. Questions and answers have separate pages.
Lesson 1 · What makes an algorithm
Describe an algorithm as precise steps from input to output, and trace one with decisions and repeats.
AnswersAnswers with the reason for each.
Which property must every algorithm have?
Answer: It must finish after a finite number of steps. A procedure that never stops gives no output, so an algorithm must end. It can be done by hand and can have any number of steps.
Start with 5. Repeat three times: double the number, then subtract 1. What is the output?
Answer: 33. 5 → 9 → 17 → 33. 17 stops after only two rounds.
The largest-value algorithm runs on 14, 9, 23, 8, 23, 17. After the first value, how many times does 'best so far' change?
Answer: 1. It changes only from 14 to 23. The second 23 is not larger than 23, so it causes no change.
Discuss: Write an algorithm a friend could follow to find the smallest mark in a list. Swap algorithms, trace each other's on the same list, and check whether both give the right answer.
Teaching note: An algorithm is not only something a computer runs. The column method for adding numbers, done with pencil and paper, is an algorithm too.
Lesson 2 · Euclid's algorithm for the HCF
Use repeated division with remainder to find the highest common factor of two numbers.
AnswersAnswers with the reason for each.
Write 85 in the form 12q + r with 0 ≤ r < 12.
Answer: 85 = 12 × 7 + 1. 12 × 7 = 84 and 85 − 84 = 1, which is less than 12. A remainder of 13 is too large, and a negative remainder is not allowed.
Use Euclid's algorithm to find the HCF of 84 and 36.
Answer: 12. 84 = 36 × 2 + 12 and 36 = 12 × 3 + 0, so the HCF is 12. 6 is a common factor but not the highest.
Use Euclid's algorithm to find the HCF of 391 and 299.
Answer: 23. 391 = 299 × 1 + 92; 299 = 92 × 3 + 23; 92 = 23 × 4 + 0. So the HCF is 23; 17 divides 391 but not 299.
Discuss: Count the divisions Euclid's algorithm needs for HCF(89, 55) and for HCF(100, 50). Suggest what kind of number pair makes the algorithm take many steps.
Teaching note: The HCF is the last non-zero remainder, not a quotient. For 252 and 105 every quotient is 2, but the HCF is 21, the divisor that leaves remainder 0.
Lesson 3 · Improving and analysing an algorithm
Count the steps an algorithm takes, cut out wasted work, and compare the subtraction and division forms of Euclid's gcd algorithm.
AnswersAnswers with the reason for each.
A gcd method checks every number from 1 up to the smaller of the two numbers. How many checks does it make for gcd(45, 75)?
Answer: 45. The smaller number is 45, so it checks 1 to 45: 45 checks. 120 = 45 + 75 counts the checks for listing both numbers' divisors separately.
One step of Euclid's subtraction form is applied to the pair (50, 15). Which pair comes next?
Answer: (35, 15). Replace the larger number by the difference: 50 − 15 = 35, giving (35, 15). (65, 15) adds instead of subtracting, and (50, 35) keeps the larger number.
How many divisions does Euclid's division form need for gcd(91, 35)?
Answer: 4. 91 = 35 × 2 + 21, 35 = 21 × 1 + 14, 21 = 14 × 1 + 7, 14 = 7 × 2 + 0: 4 divisions. 6 is the number of subtractions, and 7 is the gcd itself.
Discuss: Choose two pairs of 3-digit numbers: one pair close together and one where one number is much larger. Count the subtractions and the divisions Euclid's algorithm needs for each pair, and discuss when the subtraction form is slow.
Teaching note: A faster algorithm does not give a different answer. The subtraction and division forms of Euclid's algorithm always reach the same gcd; they differ only in how many steps they take.
Final check · form A
AnswersAnswers with the reason for each.
An algorithm says: input n; if n is even, halve it; otherwise multiply it by 3 and add 1. What is the output for n = 7?
Answer: 22. 7 is odd, so 7 × 3 + 1 = 22. 3.5 halves 7, which the algorithm does only for even numbers.
Which instruction is too vague to be a step in an algorithm?
Answer: Stir until it looks nice. 'Looks nice' depends on the person, so two people could do different things. The other steps are exact.
Use Euclid's algorithm to find the HCF of 126 and 45.
Answer: 9. 126 = 45 × 2 + 36; 45 = 36 × 1 + 9; 36 = 9 × 4 + 0. So the HCF is 9. 3 is a common factor but not the highest.
When does Euclid's algorithm stop?
Answer: When the remainder is 0. It stops when a division leaves remainder 0; that divisor is the HCF. The number of divisions depends on the numbers.
Euclid's subtraction form on (40, 16): 40 − 16 = 24, 24 − 16 = 8, 16 − 8 = 8, 8 − 8 = 0. What is the gcd, and how many subtractions were used?
Answer: gcd 8, 4 subtractions. The pair ends as (8, 0), so the gcd is 8, after 4 subtractions. 2 is the number of divisions the division form needs: 40 = 16 × 2 + 8 and 16 = 8 × 2 + 0.
Why can a simple gcd method stop checking at the smaller of the two numbers?
Answer: A common divisor cannot be larger than the smaller number. A divisor of a number is never larger than that number, so a common divisor is at most the smaller one. The gcd is not always the smaller number: gcd(8, 12) = 4.
Final check · form B
AnswersAnswers with the reason for each.
An algorithm sets total = 0, adds each of 4, 8 and 9 to the total, then outputs total ÷ 3. What does it find?
Answer: The mean, 7. The total is 21 and dividing by the count 3 gives the mean, 7. The total is only an in-between value, not the output.
Start with x = 5. Repeat 'x = x × 2' until x > 50. What is the final value of x?
Answer: 80. 5 → 10 → 20 → 40 → 80. At 40 the condition x > 50 is still false, so the loop runs once more.
Use Euclid's algorithm to find the HCF of 60 and 25.
Answer: 5. 60 = 25 × 2 + 10; 25 = 10 × 2 + 5; 10 = 5 × 2 + 0. So the HCF is 5. 10 is a remainder along the way, not the answer.
A floor is 168 cm by 120 cm. What is the largest square tile that covers it exactly with no cutting?
Answer: 24 cm. The tile side is HCF(168, 120): 168 = 120 + 48; 120 = 48 × 2 + 24; 48 = 24 × 2 + 0, so 24 cm. 48 cm does not divide 120.
One division in Euclid's algorithm, 100 = 7 × 14 + 2, does the work of how many subtractions of 7?
Answer: 14. The quotient 14 counts how many times 7 is taken away from 100 before less than 7 is left. 2 is the remainder, not the number of subtractions.
Which method needs the fewest steps for gcd(600, 5)?
Answer: Euclid's division form: 1 division. 600 = 5 × 120 + 0, so one division finishes it. Subtracting 5 needs 120 steps, and checking 1 to 5 needs 5.
Original learning companion for selected outcomes of this chapter: what makes a procedure an algorithm (precise steps, decisions and repeats), Euclid's division algorithm for the HCF, and improving and analysing an algorithm by counting its steps and comparing the subtraction and division forms of Euclid's algorithm. It does not reproduce the textbook, its activities or its exercise solutions.