Skip to main content
EnglandComputer ScienceSyllabus dot point

What types of error occur in programs, how do the standard searching and sorting algorithms work, and how do we judge an algorithm's efficiency?

Understand syntax, logic and runtime errors and correct logic errors in algorithms; understand how the standard algorithms (bubble sort, merge sort, linear search, binary search) work; and use logical reasoning and test data to evaluate an algorithm's fitness for purpose and efficiency.

A focused answer to Edexcel GCSE Computer Science 1.2.5, 1.2.6 and 1.2.7, covering syntax, logic and runtime errors, the bubble sort, merge sort, linear search and binary search, and evaluating an algorithm's efficiency.

Generated by Claude Opus 4.810 min answer

Reviewed by: AI editorial process; not yet individually human-reviewed

Have a quick question? Jump to the Q&A page

Jump to a section
  1. What this dot point is asking
  2. Error types
  3. Searching algorithms
  4. Sorting algorithms
  5. Evaluating efficiency
  6. Try this

What this dot point is asking

This Edexcel point bundles three skills: classifying program errors (syntax, logic, runtime) and fixing logic errors; knowing how the four standard algorithms (bubble sort, merge sort, linear search, binary search) work; and evaluating an algorithm's efficiency using the number of comparisons, the number of passes through a loop and the use of memory.

Error types

The discriminators matter in the exam: syntax errors are caught by the translator before the program runs; logic errors are the hardest to find because the program runs happily but gives wrong answers, so a trace table is used to locate them; runtime errors appear only for certain inputs, which is why programs are tested with a range of test data. Correcting a logic error means changing the algorithm so it produces the right result, for example fixing a < that should be <=, or initialising a total to 0 instead of leaving it unset.

Searching algorithms

Linear search works on any list, sorted or not, but for nn items it may need up to nn comparisons. Binary search needs a sorted list but is far faster, needing at most about log2n\log_2 n comparisons, because each comparison halves the remaining items. For 1000 items, linear search may take up to 1000 checks but binary search takes at most about 10, since log2100010\log_2 1000 \approx 10.

Sorting algorithms

Bubble sort is simple to write but slow on large lists, because it may make many passes, each comparing most of the list. Merge sort is more complex (it uses the idea of decomposition, splitting then merging) but is much faster on large lists. Merge sort uses more memory because it creates the sublists during the splitting and merging, which is a typical efficiency trade-off: speed against memory.

Evaluating efficiency

Edexcel rewards quoting these measures with figures. Binary search beats linear search on comparisons (at most log2n\log_2 n versus up to nn). Merge sort beats bubble sort on the number of passes for large lists, but bubble sort uses less memory. Using test data, including normal, boundary and invalid values, with logical reasoning about the expected output, is how you decide whether an algorithm is fit for purpose and where it could be made more efficient.

Try this

Q1. State one condition that must hold before a binary search can be used. [1 mark]

  • Cue. The list must be sorted (in order).

Q2. State the type of error when a program runs but always outputs the wrong total. [1 mark]

  • Cue. A logic error.

Exam-style practice questions

Practice questions written in the style of Pearson Edexcel exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.

Edexcel 20224 marksA list of 8 sorted values is to be searched. Explain why a binary search is more efficient than a linear search for this list, referring to the number of comparisons.
Show worked answer →

Explain the efficiency in terms of comparisons. A linear search checks items one at a time from the start, so in the worst case it makes up to 8 comparisons for 8 items.

A binary search checks the middle item and discards the half that cannot contain the target, halving the remaining items each comparison, so for 8 items it needs at most log28=3\log_2 8 = 3 comparisons.

So binary search makes far fewer comparisons (at most 3 versus up to 8), and the gap grows for larger lists, because each comparison removes half the data. The condition is that the list must already be sorted, which it is here.

Markers reward comparing the worst-case comparison counts, linking binary search's speed to halving the data each step, and noting that it requires a sorted list.

Edexcel 20213 marksState the type of error (syntax, logic or runtime) in each case: (a) a missing closing bracket stops the program being translated, (b) a program that should add two numbers subtracts them instead, (c) a program crashes when it divides by a value that turns out to be zero.
Show worked answer →

(a) Syntax error: the code breaks the rules of the language, so it cannot be translated or run. (b) Logic error: the program runs but produces the wrong result because the algorithm is incorrect. (c) Runtime error: the program runs but crashes during execution because of an operation it cannot complete (dividing by zero).

Markers award one mark per correct classification. The discriminators are: syntax stops translation, logic gives a wrong answer, runtime crashes while running.

Related dot points

Sources & how we know this