OCR · GCSE · Computer Science

    Course version: J277 · Version from Sept 2022

    Testing: Refining algorithms

    Testing and refining algorithms are distinct but related processes.

    Checked against the OCR J277 specification on .

    • Point 5 of 5
    • 4 key terms

    Study notes

    From the checked teaching notes for this specification point.

    The idea

    Testing and refining algorithms are distinct but related processes. Testing evaluates a program to find errors, using iterative testing during development or final testing at the end. A test plan uses normal, boundary, invalid, and erroneous data. Refining an algorithm improves its design, such as fixing errors, handling unexpected inputs robustly, or increasing efficiency. For example, if an algorithm crashes on negative numbers, refinement adds input validation. Trace tables support dry runs to track variable changes and locate logic errors (which produce incorrect results). Syntax errors break language rules and are found by translators. Effective refinement requires identifying the specific weakness and applying a targeted fix.

    What earns the marks

    • Refining an algorithm involves identifying weaknesses, such as logic errors or inefficiencies, and applying targeted fixes.
    • Trace tables are used to dry-run algorithms, tracking variable values to pinpoint exactly where logic errors occur.
    • Distinguishes logic errors, which produce incorrect results and are found by dry runs, from syntax errors, which break language rules.
    • Refinements often include adding input validation, correcting loop conditions, or removing redundant instructions to improve efficiency.
    • A suggested fix must directly address the identified error without altering the correct functionality of the original algorithm.
    • Testing uses a test plan with normal, boundary, invalid and erroneous data, and distinguishes iterative testing from final/terminal testing.

    Common mistakes and how to put them right

    • Confusing syntax and logic errors.

      Put it right: Syntax errors break language rules (e.g. missing quotes), while logic errors produce incorrect outputs.

    • Claiming a trace table finds syntax errors.

      Put it right: Trace tables track variable values to expose logic errors, while syntax errors are found by inspection or the compiler.

    • Rewriting the entire algorithm instead of refining it.

      Put it right: Identify the specific weakness and change only the relevant lines of code.

    • Failing to update variable values correctly in a trace table.

      Put it right: Carefully follow the algorithm step-by-step, updating the table only when a variable's value explicitly changes.

    • Confusing iterative testing with final/terminal testing.

      Put it right: Iterative testing is repeated during development, while final/terminal testing is carried out at the end against the full requirements.

    Exam tips

    • When asked to refine an algorithm, identify the specific line or construct containing the error and write out the corrected code; if the question provides line numbers, refer to them.
    • Use a trace table to systematically track variables during a dry run; this is the most reliable way to find hidden logic errors.
    • Do not use a trace table to look for syntax errors; check the code against the language rules instead.
    • When a question asks about testing, refer to a test plan and give examples of normal, boundary, invalid and erroneous test data.

    Try the lesson

    The start of the Testing: Refining algorithms lesson, made from checked teaching notes for this specification point.

    Have a go first

    What is meant by refining an algorithm?

    Listen

    Testing and refining algorithms are distinct but related processes. Testing evaluates a program to find errors, using iterative testing during development or final testing at the end. A test plan uses normal, boundary, invalid, and erroneous data. Refining an algorithm improves its design, such as fixing errors, handling unexpected inputs robustly, or increasing efficiency. For example, if an algorithm crashes on negative numbers, refinement adds input validation. Trace tables support dry runs to track variable changes and locate logic errors (which produce incorrect results). Syntax errors break language rules and are found by translators. Effective refinement requires identifying the specific weakness and applying a targeted fix. A strong answer earns marks for these points. Refining an algorithm involves identifying weaknesses, such as logic errors or inefficiencies, and applying targeted fixes. Trace tables are used to dry-run algorithms, tracking variable values to pinpoint exactly where logic errors occur. Distinguishes logic errors, which produce incorrect results and are found by dry runs, from syntax errors, which break language rules. Refinements often include adding input validation, correcting loop conditions, or removing redundant instructions to improve efficiency. A common slip: Confusing syntax and logic errors. Instead, syntax errors break language rules (e.g. missing quotes), while logic errors produce incorrect outputs. Exam tip: When asked to refine an algorithm, identify the specific line or construct containing the error and write out the corrected code; if the question provides line numbers, refer to them.

    See it

    A top-down flowchart. The first node, Identify weakness, branches into two nodes: Logic error or inefficiency, and Syntax error. Logic error or inefficiency leads to Dry run with trace table. Syntax error leads to Found by inspection or translator. Both of these lead to Apply targeted fix. Apply targeted fix then branches into three nodes: Add input validation, Correct loop conditions, and Remove redundant instructions.
    Shows how identifying a weakness leads to a targeted fix, distinguishing logic errors found by dry runs from syntax errors found by inspection or translators.

    Key words

    Say what each word means before you turn the card.

    Refining an algorithm

    Try answering aloud or in your head before turning the card.

    Trace tables

    Try answering aloud or in your head before turning the card.

    Syntax errors

    Try answering aloud or in your head before turning the card.

    Test plan

    Try answering aloud or in your head before turning the card.

    See every definition
    Refining an algorithm
    Improving an algorithm's design, such as fixing errors, handling unexpected inputs robustly, or increasing efficiency, by identifying the specific weakness and applying a targeted fix.
    Trace tables
    Support dry runs to track variable changes and locate logic errors, which produce incorrect results.
    Syntax errors
    Errors that break language rules and are found by translators.
    Test plan
    Uses normal, boundary, invalid, and erroneous data.

    Label the diagram

    Some boxes have lost their names. Pick the right name for each number.

    The diagram again, with 3 boxes numbered instead of named. A top-down flowchart. The first node, Identify weakness, branches into two nodes: Logic error or inefficiency, and Syntax error. Logic error or inefficiency leads to Dry run with trace table. Syntax error leads to Found by inspection or translator. Both of these lead to Apply targeted fix. Apply targeted fix then branches into three nodes: Add input validation, Correct loop conditions, and Remove redundant instructions.
    • 1Box 1

    • 2Box 2

    • 3Box 3

    0 of 3 labelled

    There is more to this lesson

    The full lesson goes on to check your understanding and help you earn the marks. Create a free account to carry on, with your progress saved.

    Carry on with the full lesson

    A week of Premium from your first lesson · Then the free plan continues · No card, no charge

    Test your understanding of Testing: Refining algorithms

    Active recall beats re-reading. Take an instant quiz now to test what you’ve learned and lock it into long-term memory.

    Take topic quiz

    A week of Premium from your first lesson · Then the free plan continues · No card, no charge