Practice Worksheet # 1 Page # 1 Topic : Trace Table
2 The following flowchart inputs two numbers, carries out a calculation and then outputs the
result.
START
INPUT u, v
Is u + v Yes OUTPUT
= 0? “Error”
No
f = (u * v)/(u + v)
OUTPUT f
(a) Complete the following table for the three sets of input data.
INPUT
OUTPUT
u v
5 5
6 -6
12 4
[3]
(b) The above algorithm has been placed in a library of routines. Give one advantage of
doing this.
[1]
Prepared By: Absar Moeen 051-2816300
Practice Worksheet # 1 Page # 2 Topic : Trace Table
14 Study the flowchart very carefully.
START
T=1
INPUT N
A X=1
T=T*X
X=X+1
B
Is X =
No N + 1?
Yes
OUTPUT T STOP
(a) Complete the table to show what outputs you would expect for the two inputs.
Input N Output T
5
1
[2]
(b) Write down a possible LOOP construct for the section A to B in the flowchart using
pseudocode.
[2]
Prepared By: Absar Moeen 051-2816300
Practice Worksheet # 1 Page # 3 Topic : Trace Table
13 Study the following flowchart very carefully:
START
INPUT X
Yes
Is X = 0? PRINT
“error”
No
STOP
T=X
N=1
T = T/10
N=N+1
No Yes
Is T < 10? PRINT N
STOP
What output would you expect if the following data was input into the flowchart?
X OUTPUT
-150
540
0
[3]
Prepared By: Absar Moeen 051-2816300
Practice Worksheet # 1 Page # 4 Topic : Trace Table
5 Study the following flowchart very carefully:
START
count = 1
total = 0
X=0
INPUT
number
Yes
Is number > 0 ? total = total + number
X=X+1
No
count = count + 1
Yes
Is count <= 10 ?
No
average = total/X
OUTPUT
average
STOP
Prepared By: Absar Moeen 051-2816300
Practice Worksheet # 1 Page # 5 Topic : Trace Table
(a) Complete the trace table for the following data set:
15, -2, 0, 8, 0, 21, -8, -12, 1, 25
count number total X average OUTPUT
[4]
(b) What is the purpose of this flowchart?
[1]
Prepared By: Absar Moeen 051-2816300
Practice Worksheet # 1 Page # 6 Topic : Trace Table
10 The following flowchart inputs ten temperatures and outputs the average (mean)
temperature and the number of temperatures which were negative (i.e. < 0).
START
N=0
sum = 0
X=0
count = 1
input T
X=X+1
sum = sum + T
Yes
is T < 0 ? N=N+1
No
count = count + 1
Yes No
is count < 11 ? average = sum/X
output
average, N
STOP
Prepared By: Absar Moeen 051-2816300
Practice Worksheet # 1 Page # 7 Topic : Trace Table
(a) Complete the trace table for this flowchart using the following test data:
5, 11, 16, -4, -10, 8, 10, -3, 17, 10
N sum X count T average
[6]
(b) What values are output from the flowchart using the above test data?
[1]
Prepared By: Absar Moeen 051-2816300
Practice Worksheet # 1 Page # 8 Topic : Trace Table
6 Carefully study the following flowchart.
START
C=1
L=0
N=0
S=0
T=0
INPUT A, B
Yes
Is A > B ? L=L+1 N=A–B
No
Yes
Is B > A ? S=S+1 N=B–A
No
N=0
T=T+N
C=C+1
No
Is C < = 10 ?
Yes OUTPUT L, S, T
STOP
Prepared By: Absar Moeen 051-2816300
Practice Worksheet # 1 Page # 9 Topic : Trace Table
(a) Complete the trace table for the following data:
8, 4, 3, 1, 5, 8, 4, 2, 1, 3, 2, 2, 1, 2, 5, 5, 4, 0, 5, 4
C L N S T A B
[6]
(b) What is the final output from the algorithm?
L=
S=
T= [2]
Prepared By: Absar Moeen 051-2816300
Practice Worksheet # 1 Page # 10 Topic : Trace Table
16 A car park uses sensors and a microprocessor to monitor cars leaving and entering.
The car park is open 24 hours every day. The parking fee is $10 per day.
The following flowchart shows how the IN and OUT barriers are controlled. Some of the
statements are missing.
Using item numbers only, insert the correct item numbers into the flowchart from the item
list.
START
read the IN
sensor
any signal No
received from read the OUT
sensor
IN sensor?
Yes
No
Yes
Yes
No
No
Yes
Prepared By: Absar Moeen 051-2816300
Practice Worksheet # 1 Page # 11 Topic : Trace Table
List of statements
Item Number Description
1 activate motor to raise IN barrier
2 activate motor to raise OUT barrier
3 any signal received from OUT sensor?
4 decrease number of cars in car park by 1
5 increase number of cars in car park by 1
6 is car park full?
7 is the car park fee paid?
8 OUTPUT “car park full”
9 OUTPUT “please pay car park fee at pay machine”
10 use ADC to convert IN sensor signal to digital
11 use ADC to convert OUT sensor signal to digital
12 use DAC to convert computer signal to analogue signal to operate IN barrier
13 use DAC to convert computer signal to analogue signal to operate OUT barrier
14 wait 30 seconds and then close barrier
[6]
Prepared By: Absar Moeen 051-2816300
Practice Worksheet # 1 Page # 12 Topic : Trace Table
8
6 Carefully study the following flowchart:
START
M = 32
T=1
S=0
C=1
INPUT D
T=D*M
M = M/2 S=S+T
C=C+1
Yes
No
OUTPUT S
STOP
Prepared By: Absar Moeen 051-2816300
Practice Worksheet # 1 Page # 13 Topic : Trace Table
(a) Complete the trace table for the following data:
1, 0, 1, 1, 0, 1
M T S C D
[4]
(b) What process does this flowchart perform?
[1]
(c) Predict the output from the flowchart for an input of 1, 1, 1, 1, 0, 0
[1]
Prepared By: Absar Moeen 051-2816300
Practice Worksheet # 1 Page # 14 Topic : Trace Table
13 A customer uses Internet banking. To gain access to their account they need:
• an 8-digit ID
• a 4-digit PIN
• a 10-character password
They will be asked to type in their ID, then 3 digits from their PIN and finally 3 characters
from their password. Three attempts at the ID are allowed, but only one attempt at the PIN
and at the password.
The flowchart on the next page shows the access process described above. However, most
of the stages have been omitted.
Complete the flowchart, using item number only, from the list of items given.
Item Item description
number
1 access to account allowed
are any characters in the password
2
incorrect?
3 are any digits in the ID incorrect?
4 are any digits in the PIN incorrect?
generate three random digits from
5
the PIN
generate three random characters
6
from the password
input the required three digits from
7
the PIN
is number of digits < 8
8
or number of digits > 8?
9 is X > 2?
10 output “access to account denied”
11 X=X+1
Prepared By: Absar Moeen 051-2816300
Practice Worksheet # 1 Page # 15 Topic : Trace Table
START
X=0
END INPUT
8-digit ID
Yes
No
Yes
No
Yes
No
Yes
No
INPUT
3 characters
from password
Yes No
END
[6]
Prepared By: Absar Moeen 051-2816300
Practice Worksheet # 1 Page # 16 Topic : Trace Table
START
INPUT N
Yes
IS N EVEN?
No
N=3N+1 N=N/2
PRINT N
No Yes
IS N = 1? STOP
Trace the flow chart using the numbers 2 and 3. Write down each of the values of N in the order
that they are printed out.
(a) 2 [1]
(b) 3
[2]
Prepared By: Absar Moeen 051-2816300