levo

Algorithms and Programs

Dry running, trace tables and test data

  • 3 things to know
  • AS Unit 1
Start revising · £5/month

Overview

What a programmer does when carrying out a dry run, trace table and test data.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

Why can a dry run reveal a logic error that simply running the program does not?

Key term

What is a trace table, and what does each column hold?

Key term

Name the three kinds of test data.

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    Describe what a programmer does when carrying out a dry run.

    Model answer

    The programmer works through the algorithm by hand one statement at a time, writing down the value of every variable as it changes, without executing it on a computer.

  2. 2

    What is a trace table, and what does each column hold?

    Model answer

    A trace table records a dry run as a grid, with one column for each variable and for any output, and one row for each step of the algorithm.

  3. 3

    An algorithm reads: total ← 0; FOR i ← 1 TO 4; total ← total + i × i; NEXT i; OUTPUT total. State the value output and the value of total after each pass.

    Model answer

    The output is 30, and total holds 1, then 5, then 14, then 30 after the four passes.

  4. 4

    A list holds 5, 3, 8, 1 and one complete pass of a bubble sort is carried out. State the order of the list afterwards.

    Model answer

    The list becomes 3, 5, 1, 8, because 5 and 3 are swapped, 5 and 8 are left alone and 8 and 1 are swapped.

  5. 5

    Ten values are held in positions 1 to 10 but the loop is written FOR i ← 1 TO 9. Describe the effect on the total calculated.

    Model answer

    The tenth value is never added, so the total is short by that value and the fault shows only when the last item is not zero.

  6. 6

    An array is indexed from 0 to 9 but is processed by a loop written FOR i ← 1 TO 10. Describe the two faults this causes.

    Model answer

    The item at index 0 is never processed, and the attempt to reach index 10 is outside the array and causes the program to fail.

Other ways to work this

The same content, four other ways.

Everything in your subscription

Runs, plus a mode for every other kind of session.

1Flash
2Imposter
3Fade
4Brain dump

Learn every subtopic in runs of four questions

Facts flash and fade, a wrong word hides in some of them, and a brain dump decides which questions are locked in.

Hardware: Architecture, Memory and Storage
Networks and Data Transmission
Logic Gates and Boolean Algebra
Data Representation and Data Types

Cram the night before, weakest topic first

A quick scan finds your weakest topics. Recall each fact you missed three times in a row.

Fetch, , execute.
decodecompilestore

Blank Blitz consolidates the facts

Rapid timed gap-fills on the terms and numbers you need to recall without thinking.

✓What it iscovered
~Why it happenspartly there
How long it lastsnot there yet

Explain It tests your understanding

Explain a concept in your own words and see which of its points you covered.

A bit is a single binary digit.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The faults are the mistakes students make most often.

721941163128510

Brain Breaks between sessions

Short focus games to reset attention, so the next set lands better than the last.

Every question in Algorithms and Programs, on a schedule.

Learn it in runs of four questions, each ending on a brain dump against the clock. Every question you lock in comes back the next day, then at longer gaps, each time just before you would forget it.

Or £46 a year, about £3.83 a month. Cancel anytime.