Programming (exam style) Questions on Standard Algorithms
Last edit: 13 June 2022
Students are provided a scenario with four parallel arrays where each array stores the air pressure of a car tyre (front left, back right etc).
Each Question asks students to write code to solve a stated problem. Answers require that students write:
- find maximum - code that finds the largest value in an array
- find minimum - code that finds the smallest value in an array
- linear search - code that traverses an array looking for values
- count occurrence - code that count the number of times values are found in an array.
The questions get progressively harder.
Although many programming languages contain functions to carry out some or all of the above, knowing how to code these algorithms aids code understanding and gives students the ability to write alternative versions of each algorithm.
Marking Instructions and a completed Python program with the solutions are supplied.
The questions are suitable for any programming language your students may be familiar with. The marking instructions could be adapted for solutions in different languages.
These could also be turned into practical tasks by providing a partial program that sets up the data in the arrays.
Greg Reid | 13.06.22
Fixed issues in marking instructions.
Greg Reid | 25.04.22
Updated 25th April 2020 as there were a couple of Copy & Paste errors in the marking instructions where the function return hadn't been updated from previous questions.
Greg Reid | 21.04.22