You are on page 1of 8

Subject: Computer Science SL

Type of exam: Binaries - Topic 4 - Trace Algorithms simple

Student’s NAME and SURNAME:

Class: DP1 A

Date: 18/10/23

1. Duration of the exam: 55 minutes


2. Calculators are not allowed
3. Write your answers in a separate sheet

4. Any non-legible answers will not be marked


5. Total marks of this exam: 34

(May 2017)
November 2019

November 2019
Nov 2018
November 2019

Teacher’s

1) State the denary number of D9 [1 mark]

13*16+9= 217

2) State the output of the following algorithms


a) First algorithm [2 marks]

A=5

B=A

C=6

A=C+1

output ( B )

B=B-1

A = C + A*2 – B // 6 + 7*2 - 4

output ( A )

5, 16

b) Second algorithm [2 marks]

A=4

B=0

C=3
B = B +1 //1

C = C -1 //2

A = B //1

B = B +1 //2

if ( B = C ) then //true

output (A) //1

C = C +1

else

output (C)

B = B +1

end if

output (B) //2

1, 2
C) Third algorithm [2 marks]

A=1

B = 10

if (( B + A ) mod 2 = 1 ) then //true

C=5

if ( A + C = 7 ) then //false

output B

C=C+2

else

output C // 5

C = C + 3 //8

end if

B=5

else if (B + A) = 6 then

C = 10

if ( A + C = 11 ) then

output C

else

B=B+C

output B

end if

B = 20

else

C = 20

output A

B = 30

end if

A = A + B + C // 1 + 5 + 8

output A // 14

5,14
3) Create a trace table (headers with the name of the variables) of this algorithm [4
marks]
A B C D
A=1
1 20 10 5
B = 20 1 20 50 5
0 20 50 5
C = 10 0 20 50 2
D=5 0 20 50 2
0 20 50 54
C=5*C 54 20 50 54
A = C mod D

D = C div B

B=B+A

D=D*D+C

A = D div (A +1)

4)
a. Looking at this algorithm state the purpose of the variables P Q and R [1 mark]

N = 354

P = N div 100

Q = (N mod 100) div 10

R = N mod 10

b. Using the same algorithm as in 4)a) state what would be the values of P, Q and
R if the value N is 687 [1 mark]

5) Outline the function of an interpreter in a High Level Programming Language [2 marks]

6) Variables in some High Level programming languages need to have types.

a. State one example of type of variable in a programming Language [1 mark]


b. Outline an advantage or a disadvantage of the use of types in High Level
Programming Languages [2 marks]

You might also like