Data representation: user-defined types, files and floating point – A Level Computer Science (old syllabus, to 2021) (9608)
13 questions · Clear filters
Question text
1
In a particular computer system, real numbers are stored using floating-point representation with:
•
10 bits for the mantissa
•
6 bits for the exponent
•
two’s complement form for both mantissa and exponent.
(a) Calculate the normalised floating-point representation of +192.5 in this system. Show your
working.
Mantissa
Exponent
Working …
…
…
…
… [3]
(b) Calculate the normalised floating-point representation of –192.5 in this system. Show your
working.
Mantissa
Exponent
Working …
…
…
…
… [3]
(c) The floating-point representation has changed. There are now 12 bits for the mantissa and 4
bits for the exponent as shown.
Mantissa
Exponent
Explain why +192.5 cannot be accurately represented in this format.
…
…
…
…
…
… [3]
Question text
2
The diagram shows four files and three methods of file organisation.
Draw one line to match each file with its most appropriate method of file organisation.
File
File organisation
Text file
Sequential
File for recording the temperature every hour
Random
Master file for paying each employee every month
Serial
Customer user name and password file
[4]
Question text
1
In a computer system, real numbers are stored using normalised floating-point representation
with:
•
twelve bits for the mantissa
•
four bits for the exponent.
The mantissa and exponent are both in two’s complement form.
(a) Calculate the denary value for the following binary floating-point number.
Show your working.
Mantissa
Exponent
1
0
0
1
0
1
1
1
0
0
1
1
0
1
1
1
Working …
…
…
…
…
Answer …
[3]
(b) Calculate the normalised floating-point representation of +1.5625 in this system.
Show your working.
Working …
…
…
…
…
…
Mantissa
Exponent
[3]
(c) (i)
Write the largest positive number that can be stored as a normalised floating-point
number using this format.
Mantissa
Exponent
[2]
(ii)
Write the smallest non-zero positive number that can be stored as a normalised
floating-point number using this format.
Mantissa
Exponent
[2]
(d) The developer of a new programming language decides that all real numbers will now be
stored using 20-bit normalised floating-point representation. She must decide how many bits
to use for the mantissa and how many bits for the exponent.
Explain the trade-off between using either a large number of bits for the mantissa, or a large
number of bits for the exponent.
…
…
…
…
…
… [3]
Question text
1
(a) A computer 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 stored in two’s complement format.
(i)
Calculate the denary value of the following floating-point number.
Show your working.
Mantissa
Exponent
0
0
1
1
0
1
1
1
0
1
0
1
Working …
…
…
…
…
Answer …
[3]
(ii)
State why the floating-point number in part (a)(i) is not normalised.
…
… [1]
(iii)
Give the floating-point number in part (a)(i) in normalised two’s complement format.
Mantissa
Exponent
[2]
(b) (i)
Convert the denary number +11.625 into a normalised floating-point number.
Show your working.
Working …
…
…
…
…
…
Mantissa
Exponent
[3]
(ii)
Convert the denary number −11.625 into a normalised floating-point number.
Show your working.
Working …
…
…
…
…
…
Mantissa
Exponent
[3]
(c) A student enters the following into an interpreter:
OUTPUT(0.2 * 0.4)
The student is surprised to see that the interpreter outputs the following:
0.08000000000000002
Explain why the interpreter outputs this value.
…
…
Question text
1
In a computer system, real numbers are stored using normalised floating-point representation
with:
•
12 bits for the mantissa
•
4 bits for the exponent
•
Two’s complement form for both mantissa and exponent.
(a) Find the denary value for the following binary floating-point number.
Mantissa
Exponent
1
0
1
1
1
0
0
1
1
0
1
0
0
1
0
1
Show your working.
Working …
…
…
…
…
Answer …
[3]
(b) Calculate the normalised floating-point representation of 5.25 in this system. Show your
working.
Working …
…
…
…
…
…
Mantissa
Exponent
[3]
(c) The size of the mantissa is decreased and the size of the exponent is increased.
State how this affects the range and precision of the numbers that the computer system can
represent.
…
…
…
… [2]
Question text
2
A programmer uses non-composite and composite data types to create a program.
(a) Define the term non-composite data type.
…
… [1]
(b) Describe two different non-composite data types.
Data type 1 …
Description …
…
…
Data type 2 …
Description …
…
…
[4]
(c) Define the term composite data type.
…
… [1]
(d) Describe two different composite data types.
Data type 1 …
Description …
…
…
Data type 2 …
Description …
…
…
[4]
Question text
6
A company specialises in educational software.
(a) The company is concerned that malware might disrupt their business.
(i)
Add appropriate descriptions and terms in the table.
Description
Term
Redirection to a bogus website that appears to be
A
legitimate to gain confidential data.
…
B
Use email to attempt to gain a user’s confidential data.
…
…
C
Spyware
…
…
…
D
Worm
…
…
[4]
(ii)
A member of staff is using the Internet to carry out research. They are worried about the
threat from terms A and B.
Identify one solution to the each of the threats.
Term A …
…
Term B …
…
[2]
(b) A customer downloads a new educational software package from the company.
Explain how the customer’s and the company’s computers use a hashing algorithm to assure
the customer that:
•
the software has come from the company (is authentic) and
•
no one has altered it.
…
…
…
…
…
…
…
… [4]
Question text
1
Data types can be defined in a programming language.
The data type, StudentRecord, is defined by the code:
TYPE StudentRecord
DECLARE StudentID
:
INTEGER
DECLARE StudentFirstName
:
STRING
DECLARE StudentSurname
:
STRING
DECLARE StudentDOB
:
DATE
DECLARE StudentCourse
:
ARRAY[1:10] OF STRING
ENDTYPE
A variable, CollegeStudent, is declared with the code:
DECLARE CollegeStudent : StudentRecord
(a) Write a pseudocode statement to assign 6539 to the StudentID of CollegeStudent.
… [1]
(b) The type definition for StudentRecord is changed.
(i)
Students can take six courses from: Computer Science, Engineering, Science, Maths,
Physics, Chemistry, Music, Drama and English Language.
Rewrite one line from the type definition of StudentRecord to implement the change.
DECLARE …
…
…
… [2]
(ii)
The values for the field StudentID must be between 1 and 8000 inclusive.
Rewrite one line from the type definition of StudentRecord to implement the change.
DECLARE … [1]
(c) A programmer is asked to write a program to process the assessment data for each student.
Students sit one exam in every course they take.
A composite data type, StudentAssessment, needs to be defined with the following three
fields.
•
a student assessment code (a unique code of three letters and two digits)
•
the marks for the six exams
•
the average mark of the six exams
(i)
Write pseudocode to define the data type StudentAssessment.
…
…
…
…
…
… [4]
(ii)
Data about all students and their assessments are stored in a file that uses random
organisation. The StudentID is used as the key field.
The program allows a user to enter data for a new student.
Explain how the program adds the new data to the file.
…
…
…
…
…
Question text
3
In a computer system, real numbers are stored using normalised-floating point representation
with:
•
8 bits for the mantissa
•
4 bits for the exponent
•
two’s complement form for both mantissa and exponent.
(a) Calculate the normalised floating-point representation of + 21.75 in this system. Show your
working.
Working …
…
…
…
…
…
Mantissa
Exponent
[3]
(b) Find the denary value for the following binary floating-point number.
Mantissa
Exponent
1
0
1
1
0
0
0
0
1
1
1
0
Show your working.
Working …
…
…
…
…
Answer …
[3]
Question text
1
(a) Consider the following user-defined data type:
TYPE LibraryBookRecord
DECLARE ISBN
: INTEGER
DECLARE Title
: STRING
ENDTYPE
(i)
Write a pseudocode statement to declare a variable, Book, of type LibraryBookRecord.
… [1]
(ii)
Write a pseudocode statement that assigns ‘Dune’ to the Title of Book.
… [1]
(b) The user-defined data type LibraryBookRecord needs to be modified by adding the
following fields:
•
a field called Genre which can take two values, fiction or non-fiction
•
a field called NumberOfLoans which can be an integer value in the range 1 to 99
Write the updated version of LibraryBookRecord.
…
…
…
…
…
…
… [3]
(c) A pointer is a variable that stores the address of a variable of a particular type.
Consider the code on page 3, which uses the following identifiers:
Identifier
Data type
Description
IntPointer
^INTEGER
pointer to an integer
IntVar
INTEGER
an integer variable
Temp1
INTEGER
an integer variable
Temp2
INTEGER
an integer variable
IntVar
57
//
assigns the value 57 to the integer
//
variable IntVar
@IntVar
//
assigns to IntPointer the address of the
IntPointer
//
integer variable IntVar
IntPointer^
//
assigns to variable Temp2 the value at an
Temp2
//
address pointed at by IntPointer
Temp1
//
assigns the value in the variable Temp1 to
IntPointer^
//
the memory location pointed at by IntPointer
The four assignment statements are executed. The diagram shows the memory contents
after execution.
Memory
Variable
Contents
address
. . .
8217
8216
88
IntVar
8215
8214
. . .
7307
7306
IntPointer
8216
7305
. . .
6717
6716
Temp1
88
6715
Temp2
57
6714
. . .
Use the diagram to state the current values of the following expressions:
(i)
@Temp2 … [1]
(ii)
IntPointer … [1]
(iii)
IntPointer^ … [1]
(iv)
IntPointer^ = Temp2 + 6 … [1]
(d) Write pseudocode statements that will achieve the following:
(i)
Assign the value 22 to the variable Temp2.
… [1]
(ii)
Place the address of Temp1 in IntPointer.
… [1]
(iii)
Copy the value in Temp2 into the memory location cu
Question text
1
(a) Consider the following pseudocode user-defined data type:
TYPE MyContactDetail
DECLARE Name
: STRING
DECLARE HouseNumber : INTEGER
ENDTYPE
(i)
Write a pseudocode statement to declare a variable, NewFriend, of type
MyContactDetail.
… [1]
(ii)
Write a pseudocode statement that assigns 129 to the HouseNumber of NewFriend.
… [1]
(b) The user-defined data type MyContactDetail needs to be modified by:
•
adding a field called Area which can take three values, uptown, downtown or midtown
•
amending the field HouseNumber so that house numbers can only be in the range 1 to
499.
Write the updated version of MyContactDetail.
…
…
…
…
…
…
… [3]
(c) A pointer is a variable that stores the address of a variable of a particular type.
Consider the pseudocode on page 3, which uses the following identifiers:
Identifier
Data type
Description
IPointer
^INTEGER
pointer to an integer
Sum
INTEGER
an integer variable
MyInt1
INTEGER
an integer variable
MyInt2
INTEGER
an integer variable
Sum
91
//
assigns the value 91 to the integer variable Sum
@Sum
//
assigns to IPointer the address of the
IPointer
//
integer variable Sum
IPointer^
//
assigns to variable MyInt1 the value at an
MyInt1
//
address pointed at by IPointer
MyInt2
//
assigns the value in the variable MyInt2 to
IPointer^
//
the memory location pointed at by IPointer
The four assignment statements are executed. The diagram shows the memory contents
after execution.
Memory
Variable
Contents
Address
. . .
5848
5847
5846
IPointer
4402
5845
. . .
4403
4402
Sum
33
4401
. . .
3428
3427
MyInt1
91
3426
MyInt2
33
3425
. . .
Use the diagram to state the current values of the following expressions:
(i)
IPointer … [1]
(ii)
IPointer^ … [1]
(iii)
@MyInt1 … [1]
(iv)
IPointer^ = MyInt2 … [1]
(d) Write pseudocode statements that will achieve the following:
(i)
Place the address of MyInt2 in IPointer.
… [1]
(ii)
Assign the value 33 to the variable MyInt1.
… [1]
(iii)
Copy the value in MyInt2 into the memory location cu
Question text
4
(a) Three file organisation methods and two file access methods are shown below.
Draw lines to link each file organisation method to its appropriate file access method(s).
File organisation method
File access method
sequential
random
serial
direct
sequential
[4]
(b) An energy company supplies electricity to a large number of customers. Each customer has
a meter that records the amount of electricity used. Customers submit meter readings using
their online account.
The company’s computer system stores data about its customers.
This data includes:
•
account number
•
personal data (name, address, telephone number)
•
meter readings
•
username and encrypted password.
The computer system uses three files:
File
Content
Use
A
Account number and meter readings
Each time a customer submits their
for the current month.
reading, a new record is added to the
file.
B
Customer’s personal data.
At the end of the month to create a
statement that shows the electricity
supplied and the total cost.
C
Usernames and encrypted passwords.
When customers log in to their
accounts to submit meter readings.
For each of the files A, B and C, state an appropriate file organisation method for the use
given in the table.
All three file organisation methods must be different.
Justify your choice.
(i)
File A organisation …
Justification …
…
…
… [3]
(ii)
File B organisation …
Justification …
…
…
… [3]
(iii)
File C organisation …
Justification …
…
…
… [3]
Question text
4
(a) Three file organisation methods and two file access methods are shown below.
Draw lines to link each file organisation method to its appropriate file access method or
methods.
File organisation method
File access method
direct
serial
sequential
sequential
random
[4]
(b) A bank has a very large number of customers. The bank stores data for each customer. This
includes:
•
unique customer number
•
personal data (name, address, telephone number)
•
transactions
The bank computer system makes use of three files:
•
A – a file that stores customer personal data. This file is used at the end of each month
for the production of the monthly statement.
•
B – a file that stores encrypted personal identification numbers (PINs) for customer bank
cards. This file is accessed when the customer attempts to withdraw cash at a cash
machine (ATM).
•
C – a file that stores all customer transaction records for the current month. Every time
the customer makes a transaction, a new record is created.
For each of the files A, B and C, state an appropriate method of organisation. Justify your
choice.
(i)
File A organisation …
Justification …
…
…
… [3]
(ii)
File B organisation …
Justification …
…
…
… [3]
(iii)
File C organisation …
Justification …
…
…
… [3]