Yr 11 - Trace tables

Trace tables
1 / 27
suivant
Slide 1: Diapositive
ComputingUpper Secondary (Key Stage 4)GCSE

Cette leçon contient 27 diapositives, avec quiz interactifs et diapositives de texte.

time-iconLa durée de la leçon est: 50 min

Éléments de cette leçon

Trace tables

Slide 1 - Diapositive

What is a trace table?
A trace table is a debugging technique used to track the value of variables and outputs, through the flow of a program.

It helps to visualise how the program progresses step by step.

Slide 2 - Diapositive

Pseudocode:
FOR x = 1 to 5
   y = x*3
   x+1
OUTPUT y

Slide 3 - Diapositive

Pseudocode:
FOR x = 1 to 5
   y = x*3
   x+1
OUTPUT y
x
y
output
First step:
Variables and outputs for table headers

Slide 4 - Diapositive

Pseudocode:
FOR x = 1 to 5
   y = x*3
   x+1
OUTPUT y
x
y
output
1

Slide 5 - Diapositive

Pseudocode:
FOR x = 1 to 5
   y = x*3
   x+1
OUTPUT y
x
y
output
1
3

Slide 6 - Diapositive

Pseudocode:
FOR x = 1 to 5
   y = x*3
   x+1
OUTPUT y
x
y
output
1
3
2

Slide 7 - Diapositive

Pseudocode:
FOR x = 1 to 5
   y = x*3
   x+1
OUTPUT y
x
y
output
1
3
2

Slide 8 - Diapositive

Pseudocode:
FOR x = 1 to 5
   y = x*3
   x+1
OUTPUT y
x
y
output
1
3
2
6

Slide 9 - Diapositive

Pseudocode:
FOR x = 1 to 5
   y = x*3
   x+1
OUTPUT y
x
y
output
1
3
2
6
3

Slide 10 - Diapositive

Pseudocode:
FOR x = 1 to 5
   y = x*3
   x+1
OUTPUT y
x
y
output
1
3
2
6
3
9

Slide 11 - Diapositive

Pseudocode:
FOR x = 1 to 5
   y = x*3
   x+1
OUTPUT y
x
y
output
1
3
2
6
3
9
4

Slide 12 - Diapositive

Pseudocode:
FOR x = 1 to 5
   y = x*3
   x+1
OUTPUT y
x
y
output
1
3
2
6
3
9
4
12

Slide 13 - Diapositive

Pseudocode:
FOR x = 1 to 5
   y = x*3
   x+1
OUTPUT y
x
y
output
1
3
2
6
3
9
4
12
5

Slide 14 - Diapositive

Pseudocode:
FOR x = 1 to 5
   y = x*3
   x+1
OUTPUT y
x
y
output
1
3
2
6
3
9
4
12
5
15

Slide 15 - Diapositive

Pseudocode:
FOR x = 1 to 5
   y = x*3
   x+1
OUTPUT y
x
y
output
1
3
2
6
3
9
4
12
5
15
15

Slide 16 - Diapositive

When would you add a value to a trace table?
A
When the software produces an output.
B
When a variable is created.
C
When a variable changes.
D
All are correct.

Slide 17 - Quiz

Challenge 1
a = 4
y = 0
FOR x = 1 to a
    y = y +(x * a)
    x + 1
OUTPUT y
Challenge 2
a = 3, b = 2, y = 0
FOR x = 1 to 5
    IF x MOD 2 = 0 THEN
          y = (a * y) + (b * x)
    ELSE
         y = y + (b * x)
    x + 1
OUTPUT y

Slide 18 - Diapositive

Challenge 1
a = 4
y = 0
FOR x = 1 to a
    y = y +(x * a)
    x + 1
OUTPUT y
Score out of 11
a
x
y
output
4
0
1
4
2
12
3
24
4
40
40

Slide 19 - Diapositive

Add up your score out of 11 and enter them below:

Slide 20 - Question ouverte

Challenge 2
a = 3, b = 2, y = 0
FOR x = 1 to 5
    IF x MOD 2 = 0 THEN
          y = (a * y) + (b * x)
    ELSE
         y = y + (b * x)
x + 1
OUTPUT y
Score out of 14
a
b
x
y
Out
3
2
0
1
2
2
10
3
16
4
56
5
66
66

Slide 21 - Diapositive

Add up your score out of 14 and enter them below:

Slide 22 - Question ouverte

Challenge 3:
a = 5, b = 0, c = 1
WHILE c <= a DO
   b = b + c
   c + 1
END WHILE

OUPUT b

a
b
c
output

Slide 23 - Diapositive

What is the purpose of a trace table in programming?
A
To write code
B
To track the values of variables
C
to execute the program
D
To design algorthms

Slide 24 - Quiz

In a trace table, each row typically represents:
A
A variable
B
A function
C
A step in the program's execution
D
A loop in the program's flow

Slide 25 - Quiz

Trace tables are particularly useful for:
A
Debugging programs
B
Writing comments
C
Testing hardware
D
Designing user interfaces

Slide 26 - Quiz

How are trace tables helpful in debugging?
A
They write code automatically
B
They highlight syntax errors
C
They track the values of variables during program execution
D
They execute the program

Slide 27 - Quiz