June 2021 (v1) QP

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

PMT

Cambridge International AS & A Level


* 2 5 7 9 4 4 0 8 6 9 *

COMPUTER SCIENCE 9618/31


Paper 3 Advanced Theory May/June 2021

1 hour 30 minutes

You must answer on the question paper.

No additional materials are needed.

INSTRUCTIONS
● Answer all questions.
● Use a black or dark blue pen.
● Write your name, centre number and candidate number in the boxes at the top of the page.
● Write your answer to each question in the space provided.
● Do not use an erasable pen or correction fluid.
● Do not write on any bar codes.
● You may use an HB pencil for any diagrams, graphs or rough working.
● Calculators must not be used in this paper.

INFORMATION
● The total mark for this paper is 75.
● The number of marks for each question or part question is shown in brackets [ ].
● No marks will be awarded for using brand names of software packages or hardware.

This document has 12 pages.

DC (LO) 213986
© UCLES 2021 [Turn over
PMT

1 Real numbers are stored in a computer system using floating-point representation with:

• 10 bits for the mantissa


• 6 bits for the exponent
• Two’s complement form for both the mantissa and the exponent.

(a) Calculate the normalised floating-point representation of –7.25 in this system.


Show your working.

Mantissa Exponent

Working .....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[3]

(b) Calculate the denary value of the given binary floating-point number.
Show your working.

Mantissa Exponent

1 0 1 1 0 0 0 1 1 1 0 0 0 1 1 1

Working .....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Answer ......................................................................................................................................
[3]

© UCLES 2021 9618/31/M/J/21


PMT

(c) The given binary floating-point number is not normalised.

Normalise the floating-point number. Show your working.

Mantissa Exponent

0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 1

Mantissa Exponent

Working .....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[3]

(d) The denary number 513 cannot be stored accurately as a normalised floating-point number in
this computer system.

(i) Explain the reason for this.

...........................................................................................................................................
More than 10 bits are required to store accuratly
...........................................................................................................................................
513 in binary will be 1000000001
which will result in overflow
...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [3]

(ii) Describe an alteration to the way floating-point numbers are stored to enable this number
to be stored accurately using the same total number of bits.

...........................................................................................................................................
the number of mantissa should be increased to 11 or 12
exponate 5 or 4
...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

© UCLES 2021 9618/31/M/J/21 [Turn over


PMT

2 (a) Describe the purpose of a user-defined data type.

...................................................................................................................................................

To create a data type from existing data types


...................................................................................................................................................
To extend the flexibility of the programing language
...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(b) Define, using pseudocode, the following enumerated data types:

(i) SchoolDay to hold data about the days students are usually in school.

...........................................................................................................................................
Type SchoolDay = (sunday monday tuesday wednesday thursday
..................................................................................................................................... [1]

(ii) WeekEnd to hold data about the days that are not school days.
Type WeekEnd= (Friday,Saturday)
...........................................................................................................................................

..................................................................................................................................... [1]

(c) Define, using pseudocode, the composite data type ClubMeet. This will hold data about club
members that includes:

• first name and last name


• the two days they attend:
○ one on a school day
○ one not on a school day.

Use the enumerated types you created in part (b).

...................................................................................................................................................

...................................................................................................................................................
Type ClubMeet
DECLARE FIRST NAME: STRING
...................................................................................................................................................
DECLARE LAST NAME:STRING
DECLARE SchoolDay:SchoolDay
...................................................................................................................................................
DECLARE WeekEnd:WeekEnd
Endtype
...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2021 9618/31/M/J/21


PMT

3 (a) Draw one line to connect each Operating System (OS) term to the most appropriate
description about it.

OS term Description

Using secondary storage to simulate


additional main memory
Multi-tasking

Managing the processes running on


the CPU
Paging

Managing the execution of many programs


that appear to run at the same time

Interrupt handling

Locating non-contiguous blocks of data and


relocating them

Scheduling
Transferring control to another routine when
a service is required

Virtual memory
Reading/writing same-size blocks of data
from/to secondary storage when required

[5]

(b) Explain how an interpreter executes a program without producing a complete translated
version of it.

...................................................................................................................................................
The interupter reads the ode one at a time
...................................................................................................................................................
if there inno error it will continue
If there is a error it will report it and stop
And the interrupter will always run when the program runs
...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2021 9618/31/M/J/21 [Turn over


PMT

4 (a) (i) Explain why Reverse Polish Notation (RPN) is used to carry out the evaluation of
expressions.

...........................................................................................................................................
reverse polish notation is amazing way of represintng an expresiion
it reads from left to right no brackets neede no bodmas needed
...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

(ii) Identify, with reasons, a data structure that could be used to evaluate an expression
in RPN.

...........................................................................................................................................
Stack:
The operand are pushed to the stack in revers order from which they where
...........................................................................................................................................
pushed into
...........................................................................................................................................

..................................................................................................................................... [2]

(b) Write the infix expression in RPN.

(a – b) * (a + c) / 7

...................................................................................................................................................

............................................................................................................................................. [1]
ab- ac+* 7/
(c) Write the RPN expression as an infix expression.

a b / 4 * a b + -

a/b 4-(a+b)
...................................................................................................................................................

............................................................................................................................................. [1]

(d) Evaluate the RPN expression:

a b + c d / /

where a = 17, b = 3, c = 48 and d = 12.

Show your working.

...................................................................................................................................................
(17+3)/(48/12)
...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2021 9618/31/M/J/21


PMT

5 (a) Calculate the shortest distance between the base and each of the other towns in the diagram
using Dijkstra’s algorithm.

Show your working and write your answers in the table provided.

Base
4
5

Town 1 2
1 Town 2
8

Town 3

7 3 Town 6
1

5
6
Town 4 Town 5

Working .....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Answers

Town 1 Town 2 Town 3 Town 4 Town 5 Town 6

[5]

© UCLES 2021 9618/31/M/J/21 [Turn over


PMT

(b) Explain the use of graphs to aid Artificial Intelligence (AI).

...................................................................................................................................................
artfical neural networks can be reprsented using graphs
Ai probelem can be solved
...................................................................................................................................................
garphs may be analised
machine learning
...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [3]

6 Give two benefits and two drawbacks of packet switching.


Accuracy ensures accurate delviery
Benefit 1 ...........................................................................................................................................

..........................................................................................................................................................
Better security because packets are hash and send by diffrent routes
Benefit 2 ...........................................................................................................................................

..........................................................................................................................................................

Time delays to correct errors


Drawback 1 ......................................................................................................................................

..........................................................................................................................................................

Drawback 2 ......................................................................................................................................

..........................................................................................................................................................
[4]

© UCLES 2021 9618/31/M/J/21


PMT

7 The diagram shows a logic circuit.

A P
Y
B

C R

Z
Q

(a) Complete the truth table for the given logic circuit. Show your working.

Inputs Working space Outputs


A B C P Q R Y Z
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
[3]
(b) State the name of the logic circuit.

............................................................................................................................................. [1]
Full adder
(c) Write the Boolean expressions for the two outputs Y and Z in the truth table as
sum-of-products and state the purpose of each output.
Y=ABC+ABC+ABC+ABC
Y = ............................................................................................................................................
Purpose: Sum bit
Purpose ....................................................................................................................................
Z=ABC+ABC+ABC+ABC
Z = ............................................................................................................................................

Purpose: Carry output


Purpose ....................................................................................................................................
[4]

© UCLES 2021 9618/31/M/J/21 [Turn over


PMT

10

8 (a) State two factors that may affect the performance of a sorting algorithm.

...................................................................................................................................................
The intial order of the data
the effinceny of sorting algorthim
...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(b) The given algorithm is a simple bubble sort that arranges a set of scores stored in a one-
dimensional array into descending order, and orders the corresponding students’ names
stored into a two-dimensional array in the same order as the scores. All the arrays are indexed
from 1.

The contents of both arrays after sorting are shown.

Name
Score
1 2
1 98 1 Smithfield Tom
2 97 2 Johnson Jane

… …

248 5 248 Peters Jade


249 3 249 Allen John



YearSize 249
Flag TRUE


WHILE Flag = TRUE


Flag FALSE
FOR Student 1 TO YearSize - 1


IF Score[Student] < Score[Student + 1] THEN


Temp1 Score[Student]


Temp2 Name[Student,1]


Temp3 Name[Student,2]


Score[Student] Score[Student + 1]


Name[Student,1] Name[Student + 1,1]


Name[Student,2] Name[Student + 1,2]


Score[Student + 1] Temp1


Name[Student + 1,1] Temp2


Name[Student + 1,2] Temp3
Flag TRUE
ENDIF
NEXT Student
ENDWHILE

© UCLES 2021 9618/31/M/J/21


PMT

11

Write an algorithm, using pseudocode, that will perform the same task using an insertion sort.

...................................................................................................................................................

...................................................................................................................................................
YearSize 249
FOR Student 2 to YearSize
...................................................................................................................................................
Temp1 Score[Student]
Temp2 Name[Student,1]
...................................................................................................................................................
Temp3 Name[Student,2]
Counter Student
...................................................................................................................................................
WHILE Counter > 1 AND Score[Counter - 1] < Temp1
Score[Counter] Score[Counter - 1]
...................................................................................................................................................
Name[Counter,1] Name[Counter - 1,1]
Name[Counter,2] Name[Counter - 1,2]
...................................................................................................................................................
Counter Counter – 1
ENDWHILE
...................................................................................................................................................
Score[Counter] Temp1
Name[Counter,1] Temp2
...................................................................................................................................................
Name[Counter,2] Temp3
NEXT Student
...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [6]

© UCLES 2021 9618/31/M/J/21 [Turn over


PMT

12

9 (a) Describe what is meant by an imperative (procedural) programming language.

...................................................................................................................................................
Imperative language uses variables
which are changed using assignments stament
...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(b) Describe what is meant by a declarative programming language.

...................................................................................................................................................
Instruct a program to what needs to be done
using facts and rules
...................................................................................................................................................
using queries to satisfy goals
...................................................................................................................................................

............................................................................................................................................. [2]

(c) Identify the programming paradigm for each of these program code examples.

Program code example Programming paradigm


male(john).
female(ethel). Declartive
parent(john, ethel).
FOR Counter = 1 TO 20 Procedure
X = X * Counter
NEXT Counter
Start: LDD Counter
INC ACC Assembly
STO Counter
public class Vehicle
{
private speed;
public Vehicle() Object orainted
{
speed = 0;
}
}
[4]

Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the
publisher will be pleased to make amends at the earliest possible opportunity.

To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.

Cambridge Assessment International Education is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of the University of
Cambridge Local Examinations Syndicate (UCLES), which itself is a department of the University of Cambridge.

© UCLES 2021 9618/31/M/J/21

You might also like