Learn › Class 9 › Mathematics › The World of Algorithms
Algorithms and flowcharts
Work it out on paper first. Then check the hint or the answer.
1. Use Euclid's algorithm to find the HCF of 84 and 36.
Hint
84 = 2 × 36 + 12, then 36 = 3 × 12 + 0.
Answer and explanation
Answer: 12
The last non-zero remainder is 12.
2. Linear search checks 50 items one at a time. In the worst case, how many checks are needed?
Hint
The target might be last or missing.
Answer and explanation
Answer: 50
It may need to check every item: 50.
3. Binary search on a sorted list of 64 items halves the range each step. At most how many halvings bring it down to 1 item?
Hint
64 → 32 → 16 → ...
Answer and explanation
Answer: 6
64, 32, 16, 8, 4, 2, 1 takes 6 halvings, since 2⁶ = 64.
4. In a flowchart, which shape shows a yes or no decision?
Hint
It has two exits.
Answer and explanation
Answer: Diamond
A diamond has one way in and two ways out: yes and no.