1. A trace table allows a programmer to list the variables and predict the output of each variable to see how the code is actually functioning.
2. A trace table is a technique used to_____ algorithms, in order to make sure that no logical errors occur whilst the algorithm is being processed
3. The advantages of using a trace table (sometimes called white box testing as the code is tested directly) includes:
4. The flowchart inputs the size of a number of car engines; a value of –1 stops the input.
Information is output. Can you fil in the second line of the trace table?
Complete the trace table (the second line) for the
following input data:
1.8, 2.0, 1.0, 1.3, 1.0, 2.5, 2.0, 1.3, 1.8, 1.3, –1
Engine ¦ Count ¦ Number ¦ Size ¦ Average ¦ OUTPUT
0 ¦ 0 ¦ 0 ¦ 1.8 ¦ ¦
---------------------------------------------------
¦ ¦ ¦ ¦ ¦
----------------------------------------------------
2.0,1,1, 2.0
1,1,1, 2.0
1.8,1,1, 2.0
1.8,1,1, 1.8
5. A woman invests £200 on January 1 for each of three years in a fixed income bond that pays interest of 8 per cent per annum, the interest being added to her account at the end of each year.
6. Trace the algorithm (first and second lines) when A = 1 and B = 1.
The algorithm below is used to generate a sequence of numbers.
LINE 10 INPUT A, B
LINE 20 PRINT A, B
LINE 30 LET C = A + B
LINE 40 PRINT C
LINE 50 LET A = B
LINE 60 LET B = C
LINE 70 IF C < 10 THEN GOTO LINE 30
LINE 80 END
A = 1, B=1, C=3 and second line A = 2, B = 3, C = 4
A = 1, B=1, C=2 and second line A = 1, B = 1, C = 4
A = 1, B=1, C=2 and second line A = 1, B = 2, C = 3
A = 1, B=2, C=3 and second line A = 1, B = 2, C = 3
7. John uses internet banking. This pseudocode checks his pin. Trace the logic to predict the value of c and what message would be output if 5 1 0 2 0 was entered?
8. This pseudocode checks the entered PIN. Trace the logic to predict the value of c and what message would be output if 5 1 2 0 was entered?
9. A student is using the algorithm below. Trace the algorithm in the case where A = 5 and B = 3. Is the answer shown correct? If not, why?
10. The user enters an input of 2. Is the trace table below correct?