Data representation: user-defined types, files and floating point – A Level Computer Science (old syllabus, to 2021) (9608)
17 questions · page 1 of 2 · Clear filters
Question text
1
Data types can be defined using pseudocode.
The data type, ComputerRecord, is defined by the following pseudocode:
TYPE ComputerRecord
DECLARE ComputerID
: INTEGER
DECLARE ComputerType
: (Laptop, Desktop, Tablet)
DECLARE ComputerLocation : (Lab1, Lab2, Lab3, Mobile)
DECLARE DateTested
: DATE
ENDTYPE
A variable, SchoolComputer, is declared in pseudocode as:
DECLARE SchoolComputer : ComputerRecord
(a) Write pseudocode statements to assign 1234 to the ComputerID of SchoolComputer
and Lab2 to the ComputerLocation of SchoolComputer.
…
… [2]
(b) The type definition for ComputerRecord is changed.
(i)
The definition has been extended to include the student identification numbers,
StudentID, for up to 20 students who can use that computer. Each student identification
number is an integer.
Write the extra line of pseudocode needed in the type definition for ComputerRecord.
…
… [1]
(ii)
The values for the field ComputerID must be between 1000 and 1999 inclusive.
Rewrite one pseudocode line from the type definition of ComputerRecord to implement
the change.
…
… [1]
(c) Data about all the computers are stored in a file that uses random file organisation.
ComputerID is used as the key field.
Explain how a program could search for a record stored in this file.
…
…
…
…
…
… [3]
Question text
1
Data types can be defined using pseudocode.
The data type, BicycleRecord, is defined in pseudocode as:
TYPE BicycleRecord
DECLARE BicycleID
:
INTEGER
DECLARE BicycleAvailable :
BOOLEAN
DECLARE BicycleLocation : (RiverSide, BusStation, TrainStation,
TownSquare, Library)
DECLARE DateChecked
:
DATE
ENDTYPE
A variable, LoanBicycle, is declared in pseudocode as:
DECLARE LoanBicycle : BicycleRecord
(a) Write pseudocode statements to assign 567 to the BicycleID of LoanBicycle and
FALSE to the BicycleAvailable of LoanBicycle.
…
… [2]
(b) The type definition for BicycleRecord is changed.
(i)
The definition has been extended to include borrower identification numbers,
BorrowerID, for the last 10 people who borrowed a bicycle. Each identification number
is an integer.
Write the pseudocode statement needed in the type definition of BicycleRecord.
…
… [1]
(ii)
The values for the field BicycleID must be between 500 and 599 inclusive.
Rewrite one pseudocode line from the type definition of BicycleRecord to implement
the change.
…
… [1]
(c) Data about all the bicycles are stored in a file that uses random file organisation.
BicycleID is used as the key field.
Explain how a program could add an extra record to this file.
…
…
…
…
…
… [3]
Question text
1
In a particular computer system, real numbers are stored using floating-point representation with:
•
12 bits for the mantissa
•
4 bits for the exponent
•
two’s complement form for both mantissa and exponent.
(a) The following floating-point number stored is not normalised.
Calculate the denary value for the floating-point number. Show your working.
Mantissa
Exponent
0
0
0
0
1
1
0
0
0
0
0
0
0
1
0
1
Working …
…
…
…
Denary value …
[3]
(b) (i)
Normalise the floating-point number given in part (a).
Write your answer in the following boxes.
Mantissa
Exponent
[2]
(ii)
Describe one problem that can occur when floating-point numbers are not normalised.
…
…
… [2]
Question text
2
Data types can be classified as composite or non-composite.
A record is declared of type box using the following pseudocode.
TYPE size = (small, medium, large)
TYPE box
DECLARE volume : size
DECLARE price : REAL
DECLARE colour : STRING
ENDTYPE
DECLARE myBox : ARRAY [1:6] OF box
(a) (i)
Identify one composite and three non-composite data types used in the pseudocode.
Composite data type …
Non-composite data type 1 …
Non-composite data type 2 …
Non-composite data type 3 …
[4]
(ii)
Identify the data type in the pseudocode that is enumerated.
… [1]
(b) A box is red, with medium volume and a price of $10.99.
Write pseudocode to store the details of this box in the first element of the array.
…
…
…
…
… [3]
Question text
1
In a particular computer system, real numbers are stored using floating-point representation, with:
•
12 bits for the mantissa
•
4 bits for the exponent
•
two’s complement form for both mantissa and exponent.
(a) Calculate the denary value for the following floating-point number. Show your working.
Mantissa
Exponent
0
1
0
1
0
0
0
0
0
0
0
0
0
1
1
0
Working …
…
…
…
Denary value …
[3]
(b) A new operating system has been installed that has changed the way the floating-point
numbers are used. The order of the exponent and the mantissa are reversed.
(i)
Calculate the new denary value for the following floating-point number that has the same
bit pattern as the number in part (a). Show your working.
Exponent
Mantissa
0
1
0
1
0
0
0
0
0
0
0
0
0
1
1
0
Working …
…
…
…
Denary value …
[3]
(ii)
Identify two problems that can occur due to the change in the representation of the
floating-point number.
Problem 1 …
…
Problem 2 …
…
[2]
Question text
2
Data types can be classified as composite or non-composite.
(a) Draw one line from each data type to its correct classification.
Data type
Classification
Pointer
Record
Composite
Set
Class
Non-composite
Integer
[2]
(b) A user-defined data type, timeOfDay, is declared using the following pseudocode.
TYPE timeOfDay = (morning, afternoon, evening, night)
(i)
Identify the type of user-defined data type declared and state its classification.
Type …
Classification …
[2]
(ii)
Write pseudocode to declare the variable session of type timeOfDay.
Assign the value afternoon to the variable session.
…
…
…
… [2]
Question text
1
Real numbers are stored using floating-point representation in a computer system.
This representation uses:
•
8 bits for the mantissa, followed by
•
4 bits for the exponent.
Two’s complement form is used for both the mantissa and the exponent.
(a) (i)
A real number is stored as a 12-bit normalised binary number as follows:
Mantissa
Exponent
0
1
0
1
0
0
1
0
0
0
1
0
Calculate the denary value for this binary number. Show your working.
Working …
…
…
Denary value …
[3]
(ii)
Calculate the normalised binary number for −3.75. Show your working.
Mantissa
Exponent
Working …
…
…
…
[3]
(b) The number of bits available to represent a real number is increased to 16.
State the effect of increasing the size of the exponent by 4 bits.
…
… [1]
(c) State why some binary representations can lead to rounding errors.
…
… [1]
(d) Complete the following descriptions by inserting the two missing terms.
… can occur in the exponent of a floating-point number, when the
exponent has become too large to be represented using the number of bits available.
A calculation results in a number so small that it cannot be represented by the number of bits
available. This is called … .
[2]
Question text
5
(a) Explain why user-defined data types are necessary.
…
…
…
… [2]
(b) An organisation stores data about its employees.
•
Employee ID is a five-digit number, for example, 01234.
•
Employee name is a string, for example, ‘Kiri Moana’.
•
Department is one of three values: Sales, Technical, Customer services.
•
Salary is an integer value in the range 25 000 to 150 000.
(i)
Complete the following pseudocode definition of a user-defined data type to store the
employee data.
TYPE Employee
…
DECLARE EmployeeID
:
DECLARE EmployeeName :
STRING
( …
DECLARE Department
:
… )
DECLARE Salary
:
25000..150000
…
[4]
(ii)
Write a pseudocode statement to declare a variable, NewEmployee of data type
Employee.
…
… [1]
(iii)
Write a pseudocode statement that assigns 02244 to the EmployeeID of
NewEmployee.
…
… [1]
(iv)
Employee is an example of a record that is a composite data type.
State two other composite data types.
1 …
2 …
[2]
Question text
9
(a) The following incomplete table shows descriptions relating to computer architectures.
Complete the table by inserting the appropriate terms.
Description
Term
• There are several processors.
A
• Each processor executes different sets of instructions …
on one set of data at the same time.
• The processor has several ALUs.
B
• Each ALU executes the same set of instructions on …
different sets of data at the same time.
• There is only one processor.
C
• The processor executes one set of instructions on one …
set of data.
• There are several processors.
D
• Each processor executes a different set of instructions. …
• Each processor operates on different sets of data.
[4]
(b) State three characteristics of massively parallel computers.
1 …
…
2 …
…
3 …
…
[3]
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
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
Question text
5
A weather station uses monitoring and control systems.
(a) Describe the difference between a monitoring system and a control system.
…
…
…
… [2]
(b) (i)
The weather station records how the outside temperature changes over a period of time.
The system will read the temperature once every hour, over a period of 100 days.
The temperature readings are automatically stored in a file. No other data are stored.
Explain why the weather station has decided to use serial organisation for the file.
…
…
…
… [2]
(ii)
Serial files can be accessed using sequential access.
Explain how sequential access could be used for the temperature readings file.
…
…
…
… [2]
(iii)
Name and describe a method of file organisation other than serial or sequential.
Method …
Description …
…
…
…
…
…
[4]
Question text
6
(a) State what is meant by a user-defined data type.
…
… [2]
(b) A pseudocode declaration for a user-defined data type for the months of the year is as follows:
TYPE
DECLARE Months: ( January, February, March, April, May, June, July,
August, September, October, November, December)
ENDTYPE
(i)
Identify this type of user-defined data type.
…
… [1]
(ii)
Write a pseudocode statement to declare a variable CurrentMonth of data type
Months.
…
… [1]
(iii)
Write a pseudocode statement to assign the value August to the variable
CurrentMonth.
…
… [1]
Question text
8
(a) The following 16-bit binary pattern represents a floating-point number stored in two’s
complement form. The twelve most significant bits are used for the mantissa and the four
least significant bits are used for the exponent.
Most
Least
significant bit
significant bit
0
1
1
1
0
0
0
0
0
0
0
0
1
1
0
1
(i)
Identify the binary value of the exponent.
… [1]
(ii)
Identify the binary value of the mantissa.
… [1]
(iii)
State whether the number stored is positive or negative. Justify your choice.
Positive or negative …
Justification …
…
…
[2]
(iv)
Convert the binary floating-point number in part (a) into denary. Show your working.
Working …
…
…
…
…
Denary value …
[3]
(b) The number of bits used for the exponent is increased to eight, and the number of bits used
for the mantissa is decreased to eight.
State the effects of this change.
…
…
…
… [2]
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
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
Question text
1
Consider the following user‑defined data type.
TYPE Book
DECLARE
ISBN
:
INTEGER
DECLARE
Author
:
STRING
DECLARE
Title
:
STRING
DECLARE
Supplier
:
(Amazone, Stones, Smiths, Blackwalls, Greens,
Coals, Boarders)
ENDTYPE
(a) Name the data type of Book.
… [1]
(b) Name the non‑composite data type used in the Supplier declaration.
… [1]
(c) (i)
Write a pseudocode statement to declare a variable, BestSeller, of type Book.
… [1]
(ii)
Write a pseudocode statement to assign “John Williams” to the author of
BestSeller.
… [1]
Question text
2
(a) A computer system stores real numbers using floating‑point representation. The floating‑point
numbers have:
•
eight bits for the mantissa
•
four bits for the exponent.
The mantissa and exponent are both in two’s complement form.
(i)
Calculate the denary value of the following floating‑point number.
Mantissa
Exponent
0
0
1
1
1
0
0
0
0
1
1
1
Show your working.
Working …
…
…
…
…
Answer …
[3]
(ii)
State how you know the floating‑point number in part (a)(i) is not normalised.
…
… [1]
(iii)
Normalise the floating‑point number in part (a)(i).
Mantissa
Exponent
[2]
(b) (i)
Write the largest positive number that this system can represent as a normalised
floating‑point number in this format.
Mantissa
Exponent
[2]
(ii)
Write the smallest positive number that can be stored as a normalised floating‑point
number in this format.
Mantissa
Exponent
[2]
(c) The number of bits available to represent a real number is increased to 16.
State the effect this has on the numbers that can be represented, if the additional four bits are
used in the:
(i)
mantissa …
… [1]
(ii)
exponent …
… [1]
(d) A student enters the following code into an interpreter.
X = 0.1
Y = 0.2
Z = 0.3
OUTPUT (X + Y + Z)
The student is surprised to see the output:
0.6000000000000001
Explain why this is output.
…
…
…
…
…
… [3]
Question text
1
(a) A computer system uses floating-point representation to store real numbers. The floating-point
numbers have:
•
8 bits for the mantissa
•
8 bits for the exponent
The mantissa and exponent are both in two’s complement form.
(i)
Calculate the denary value of the following floating-point number. It is not in normalised
form.
Mantissa
Exponent
0
0
1
0
1
0
1
0
0
0
0
0
0
1
0
1
Show your working.
Working …
…
…
…
…
Answer …
[3]
(ii)
Convert the denary number + 7.5 into a normalised floating-point number.
Show your working.
Mantissa
Exponent
Working …
…
…
…
…
[3]
(iii)
Convert the denary number − 7.5 into a normalised floating-point number.
Show your working.
Mantissa
Exponent
Working …
…
…
…
…
[3]
(b) A normalised floating-point number is shown.
Mantissa
Exponent
0
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
(i)
State the significance of this binary number.
…
… [1]
(ii)
State what will happen if a positive number is added to this number.
…
… [1]