Here is the pseudo-code for an algorithm designed to count how many recorded temperatures are over 30 degrees.
SET count TO 0
FOR EACH temp FROM temperatures DO
IF (temp > 30) THEN
SET count TO count + 1
END IF
END FOREACH
SEND "Hot days: " & count TO DISPLAY
Here is a small dataset sorted in descending order. It is stored in the array called temperatures:
28, 25, 22, 19, 15, 12
Describe one inefficiency when executing this algorithm with this dataset.
159 exam-style questions on Edexcel GCSE Computer Science Algorithms, covering Constructs for solving problems, Variables, constants and data structures, Arithmetic, relational and logical operators, Tracing algorithm output with trace tables, Types of error and correcting logic errors, Standard algorithms (sorts and searches), and Evaluating algorithm fitness and efficiency. Each one has a worked solution and a mark scheme showing where the marks go.