TutorChase logo
Login
AQA A-Level Computer Science

4.1.2 Understanding and writing algorithms

An algorithm is a finite, well-defined sequence of instructions designed to solve a specific problem or perform a task. Each step in an algorithm should be clear, unambiguous, and effective, ensuring the task is completed in a predictable and logical manner. Algorithms are deterministic, meaning the same input will always produce the same output if the instructions are followed correctly.

For an algorithm to be considered valid, it must meet the following essential properties:

Finiteness

The algorithm must terminate after a finite number of steps. This ensures that it doesn't continue running indefinitely. For example, a sorting algorithm must eventually finish sorting the list. Infinite loops are only acceptable when they are an intentional part of ongoing processes, such as in operating systems or server applications.

Definiteness

Every instruction in an algorithm must be precise and unambiguous. This means that there should be no confusion about what each step means or how it should be executed.

Input

An algorithm can have zero or more inputs, which are the values it uses at the start of execution. For example, an algorithm that calculates the square of a number takes that number as input.

Output

A correct algorithm must produce at least one output. This is the result that solves the problem or completes the task. For example, the output of a sorting algorithm is a sorted list.

Take your grades to the next level!

UPGRADING TO PREMIUM UNLOCKS
AI Tutor
AI-powered study assistant
instant feedback and guidance
Predicted Papers
Examiner-style predicted papers
based on recent exam trends
Practice Questions
All exam practice questions
by topic for each subject
Study Notes
All detailed revision notes
written by expert teachers
Cheat Sheets
Quick revision summaries
perfect for last-minute review
Past Papers
Complete collection
of practice and past exam papers
Email
Password
Confirm Password
Already have an account?

Practice Questions

FAQ

WHILE, FOR, and REPEAT UNTIL loops each serve different purposes, and understanding their control flow is key to choosing the right one. A WHILE loop is pre-condition and checks the condition before any iteration. It may not run at all if the condition is initially false, making it ideal when you're not sure whether the loop needs to run. FOR loops are count-controlled and run a fixed number of times, usually when the number of iterations is known beforehand, such as iterating through array indices or printing a set number of lines. REPEAT UNTIL loops are post-condition and always execute at least once because the condition is only checked after the first iteration. This makes them suitable for situations like user input validation, where the process should happen at least once before any checking. Knowing when to use each one improves the accuracy and efficiency of algorithm design.

One common mistake is mixing real programming syntax with pseudocode, such as using language-specific functions like print() or input() rather than general output and input statements. Another error is omitting key elements like initialising variables before use or forgetting to close loops and conditional branches with appropriate END statements. Students also often fail to maintain consistent indentation, making logic difficult to follow. Ambiguity in instructions is another issue—phrases like “do something” without defining “something” lack definiteness. To avoid these, students should practise writing structured pseudocode with clear indentation, use standard control flow constructs (e.g. IF...THEN...ELSE, WHILE...DO), and focus on clarity rather than brevity. Including comments can also help clarify intent. Regular hand-tracing can highlight weaknesses in logic and expose uninitialised variables or missing branches. Familiarity with exam-board pseudocode conventions is crucial to writing correct and understandable algorithms in assessments.

To determine which of two correct algorithms is more efficient, you analyse both time complexity and space complexity. Time complexity considers how the algorithm’s execution time increases with input size. An algorithm that performs fewer operations as input grows is more time-efficient. For example, an algorithm that sorts using O(n log n) operations will generally outperform one that sorts using O(n^2) operations on large data sets. Space complexity measures how much additional memory is used. An in-place sorting algorithm with O(1) space complexity is more efficient than one requiring O(n) auxiliary space. You can evaluate time complexity by counting loops and nested operations, and evaluate space by observing the number of variables and data structures. Even when outputs are identical, efficiency impacts how well the algorithm scales, especially in systems with limited resources or when real-time performance is required. Profiling and benchmarking with real data also support efficiency comparison.

An algorithm with no inputs might seem limited, but it can still perform useful tasks by operating with internally defined values or constants. For example, an algorithm to display a predefined message or generate the first ten square numbers does not require user input. These are often used in diagnostics, demonstrations, or automated scripts that carry out a fixed process each time they run. Such algorithms are useful in testing environments, background system tasks like log cleaners, or automated simulations with set parameters. The absence of input means that the behaviour of the algorithm is entirely predictable, making it ideal for tasks requiring consistency. In embedded systems, these algorithms might perform start-up routines or calibration sequences. Although limited in flexibility, input-free algorithms are often simpler to implement, easier to debug, and suitable for tasks where variability is not required.

Abstraction in pseudocode allows you to hide lower-level details and focus on the core logic of a solution. Instead of specifying every minor step, you can represent complex operations with descriptive names such as “sort list” or “validate input.” This helps break down large problems into manageable subprocedures or modules, improving clarity and making development more efficient. It also supports modular thinking, where parts of the algorithm can be refined independently, tested in isolation, and reused. Abstraction helps prevent cognitive overload during planning by keeping focus on what the algorithm is doing rather than how it's doing it. For instance, in a sorting algorithm, you can abstract the comparison and swapping steps into helper procedures, which makes the main logic easier to follow. In exams, abstraction ensures your pseudocode is readable and concise while still conveying the intended behaviour, which is especially important under time pressure.

Hire a tutor

Please fill out the form and we'll find a tutor for you.

1/2
Your details
Alternatively contact us via
WhatsApp, Phone Call, or Email