Vehicles are counted as they pass through automated toll booths on a bridge.
There are currently six toll booths operating, but this number may change.
A toll booth sends a signal to the central system when a vehicle passes. Each time a signal is received, the system increments the count for that specific booth. The program stores these counts in a two-dimensional array named boothCounts as shown below:
ARRAY boothCounts
SET boothCounts TO [[12, 0], [15, 0], [11, 0], [14, 0], [13, 0], [16, 0]]
INTEGER inBooth
Write an algorithm to search the two-dimensional array for the booth that matches inBooth and increment its vehicle count by 1.
inBooth holds the ID of the booth that has sent the signal (e.g., 15).boothCounts array changes.Practise Edexcel GCSE Computer Science Develop code with exam-style questions for GCSE Computer Science. 57 questions covering Decomposition and abstraction to solve problems, Read, write, analyse and refine programs, Converting algorithms into programs, Techniques for readable, maintainable code, Identifying and correcting program errors, and Evaluating program fitness and efficiency, matched to the Edexcel GCSE Computer Science (1CP2) specification and written in Paper 1 and Paper 2 style. Every question includes a full worked solution and mark scheme, so you can see where marks are awarded rather than just whether you got the answer right.