levo

Algorithms and Programs

Dry running, trace tables and test data

  • 3 things to know
  • AS Unit 1

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.

What is inside Levo

Six ways to work the same material.

1Closed book
2Open book
3Closed book

The 3-step method, run for you

Answer cold, learn it, then prove it stuck. Levo tracks the jump between your first attempt and your last.

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

Cram a whole paper in one sitting

Sort every topic into what you know and what you do not, then drill only the weak ones.

Fetch, , execute.
decodecompilestore

Blank Blitz makes facts automatic

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

AEncryption is reversible.
BThe stored form could be decrypted.
CA hash cannot be reversed.

Build It gets the exam shape right

Assemble a full-mark answer from its marking points, in the order an examiner wants them.

A bit is a single binary digit.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The traps are the mistakes students actually make.

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.

Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.

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