The flowchart shows an algorithm.
(a) Complete a trace table with columns n, count and output for the algorithm when the input is 6. [4]
(b) State the output when the input is 1. [1]
- (a) count starts at 0 and n values 3, 10, 5 in order(1)
- (a) n values 16, 8, 4 in order(1)
- (a) n values 2, 1 in order (loop then ends)(1)
- (a) count increases by 1 with each new n value, reaching 8, and the only output is 8. Follow through if one earlier n value is wrong but the count matches the number of rows.(1)
- (b) 0 (the loop never runs because 1 > 1 is false)(1)
- Answer: (a) n: 6, 3, 10, 5, 16, 8, 4, 2, 1; count: 0 to 8; output 8. (b) 0
- Examiner tip: Follow the loop arrow back to the n > 1 decision every time. Students often stop one step early or forget the count update.