Data representation: user-defined types, files and floating point – A Level Computer Science (9618)

60 questions · page 4 of 4

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
46
9618/31/M/J/23 · Question 3May/June 2023Paper 316 marks
Loading question…
Question text

3
(a) A hashing algorithm is used to calculate storage locations for records in a random access file.
It calculates hash values by using the function modulus 3.
The function modulus gives the remainder after integer division.
For example, 1030 modulus 3 = 1. Therefore, the record key 1030 gives a hash value of 1.
Complete the table to show the remaining hash values.
Record key
Hash value
1030
1
1050
1025
[2]
(b) Describe what happens, in relation to the storage or retrieval of a record in the file, when
the calculated hash value is a duplicate of a previously calculated hash value for a different
record key.
…
…
…
…
…
…
…
… [4]

47
9618/31/M/J/23 · Question 4May/June 2023Paper 314 marks
Loading question…
Question text

4
Two descriptions of user-defined data types are given.
Give appropriate type declaration statements for each, including appropriate names.
(a) A data type to hold a set of prime numbers below 20. These prime numbers are:
2, 3, 5, 7, 11, 13, 17, 19
…
…
…
… [2]
(b) A data type to point to a day in the week, for example Monday.
…
…
…
… [2]

48
9618/32/M/J/23 · Question 1May/June 2023Paper 325 marks
Loading question…
Question text

1
Numbers are stored in a computer using floating point representation with:
•
10 bits for the mantissa
•
6 bits for the exponent
•
two’s complement form for both the mantissa and exponent.
(a) Write the normalised floating‑point representation of the following binary number using this
system:
0101010.111
Show your working.
Working …
…
…
…
…
Mantissa
Exponent
[2]
(b) Describe the reason why the normalised form of the following binary number cannot be
represented accurately using this system.
0101011.111001
…
…
…
…
…
… [3]

Advertisement
49
9618/32/M/J/23 · Question 2May/June 2023Paper 325 marks
Loading question…
Question text

2
(a) Describe how records are organised and accessed in a sequential file.
…
…
…
…
…
… [3]
(b) A hashing algorithm is used to calculate storage locations for records in a random access file.
The algorithm calculates hash values using the function modulus 5.
The function modulus gives the remainder after integer division.
For example, 3003 modulus 5 = 3, so the record key 3003 gives a hash value of 3.
Complete the table to show the remaining hash values.
Record key
Hash value
3003
3
1029
7630
[2]

50
9618/32/M/J/23 · Question 6May/June 2023Paper 329 marks
Loading question…
Question text

6
(a) Write pseudocode statements to declare the composite data type, TAppointments, to hold
data about patients for a dental clinic. It will include for each patient:
•
name (first name and last name)
•
date of birth
•
telephone number
•
date of last appointment
•
date of next appointment
•
all treatments are complete (yes or no).
…
…
…
…
…
…
…
… [4]
(b) This pseudocode algorithm reads dental records stored in a random file using the user‑defined
data type TAppointments and prints the contents of the file, one record at a time.
Complete this file handling pseudocode:
DECLARE DentalRecord : ARRAY[1:250] OF TAppointments
DECLARE DentalFile : STRING
DECLARE Count : INTEGER
"DentalFile.dat"
DentalFile
OUTPUT "The file ", DentalFile, " contains these records:"
OPENFILE …
…
1
REPEAT
SEEK DentalFile, Count
…
OUTPUT DentalRecord[Count]
Count + 1
Count
… (DentalFile)
…
[5]

51
9618/31/O/N/22 · Question 1Oct/Nov 2022Paper 319 marks
Loading question…
Question text

1
Real numbers are stored in a computer system using floating-point representation with:
•
8 bits for the mantissa
•
8 bits for the exponent
•
two’s complement form for both mantissa and exponent.
(a) Write the normalised floating-point representation of +202 in this system.
Show your working.
Mantissa
Exponent
Working …
…
…
…
…
…
[3]
(b) Write the normalised floating-point representation of –202 in this system.
Show your working.
Mantissa
Exponent
Working …
…
…
…
…
…
[3]
(c) A binary number is stored in the computer system.
Mantissa
Exponent
0
0
0
1
1
1
1
0
0
0
0
1
1
0
0
0
(i)
State why the number is not normalised.
…
… [1]
(ii)
Write the normalised floating-point representation of the number.
Mantissa
Exponent
[2]

52
9618/31/O/N/22 · Question 3Oct/Nov 2022Paper 318 marks
Loading question…
Question text

3
(a) State what is meant by the term enumerated data type.
…
… [1]
(b) State what is meant by the term pointer data type.
…
… [1]
(c) The months of the year are: January, February, March, April, May, June, July, August,
September, October, November and December.
Write the pseudocode statement to define the data type Quarter1, to hold the names of the
first three months of a year.
…
…
…
… [2]
(d) The composite data type Pet is used to store data about the various pets of a group of
students. It uses these fields:
Field name
Data type
PetName
String
AnimalType
String
PetAge
Integer
PetGender
Char
OwnerName
String
(i)
Write the pseudocode statement to set up a variable for one record of the composite
data type Pet.
…
… [1]
(ii)
Write pseudocode to store the details of the following pet, in the variable you set up in
part (d)(i).
PetName
AnimalType
PetAge
PetGender
OwnerName
Tibbles
Cat
8
M
Jasmine Smith
…
…
…
…
…
… [3]

53
9618/32/O/N/22 · Question 1Oct/Nov 2022Paper 326 marks
Loading question…
Question text

1
Normalised floating-point numbers are stored in a computer system using two’s complement for
both the mantissa and the exponent with:
•
11 bits for the mantissa
•
5 bits for the exponent.
(a) Write the largest positive two’s complement binary number that can be stored in this system.
Mantissa
Exponent
[1]
(b) Calculate the denary value of the given binary floating-point number.
Show your working.
Mantissa
Exponent
1
0
1
1
0
0
1
0
0
1
1
0
1
0
0
1
Working …
…
…
…
…
Answer …
[3]
(c) State when underflow occurs in a binary floating-point system.
…
…
…
… [2]

Advertisement
54
9618/32/O/N/22 · Question 4Oct/Nov 2022Paper 3210 marks
Loading question…
Question text

4
A program to manage regular flight details at an airport requires some user-defined data types.
(a) Write pseudocode statements to declare the enumerated data type Aircraft to hold data
about the types of aircraft used for a flight.
These types of aircraft are: C300, C350, D242, E757, X380.
…
…
…
… [2]
(b) Write pseudocode statements to declare the composite data type Flight to hold data about
flights to a specific destination. These include:
•
flight number, which could be any combination of letters and numbers
•
destination
•
date of departure
•
type of aircraft used.
Use the enumerated data type you created in part (a).
…
…
…
…
…
…
…
… [4]
(c) (i)
Write the pseudocode statement to set up a variable for one record of the composite
data type Flight.
…
… [1]
(ii)
Write pseudocode to store the details of the following flight in the variable you set up in
part (c)(i).
Field
Data
flight number
XA782
destination
Cambridge
date of departure
12/12/2022
type of aircraft used
C350
Use the field names you created in part (b).
…
…
…
…
…
… [3]

55
9618/31/M/J/22 · Question 1May/June 2022Paper 318 marks
Loading question…
Question text

1
Data types can be defined using pseudocode.
The data type, LibraryRecord, is defined in pseudocode as:
TYPE LibraryRecord
DECLARE Title : STRING
DECLARE Fiction : BOOLEAN
DECLARE Author : STRING
DECLARE NumberOfCopies : INTEGER
ENDTYPE
A variable, LibraryBook, is declared in pseudocode as:
DECLARE LibraryBook : LibraryRecord
(a) Write pseudocode statements to assign:
•
A Level Computer Science to Title of LibraryBook
•
FALSE to Fiction of LibraryBook.
…
…
…
… [2]
(b) The type definition for LibraryRecord is changed.
(i)
The value for NumberOfCopies must be between 1 and 10 inclusive.
Write the updated line of pseudocode from the type definition of LibraryRecord to
implement the change.
…
… [1]
(ii)
Every copy of every book is now uniquely identified by an accession number,
AccessionNumber, as it is added to the library. Each library record will include one or
more accession numbers. Each accession number is an integer.
Write the extra line of pseudocode needed in the type definition of LibraryRecord.
…
…
…
… [2]
(c) A record is a user-defined composite data type.
Explain what is meant by a user-defined composite data type.
Include an example of another user-defined composite data type in your answer.
…
…
…
…
…
…
[3]

56
9618/31/O/N/21 · Question 1Oct/Nov 2021Paper 317 marks
Loading question…
Question text

1
(a) Numbers are stored in a computer using floating-point representation with:
•
12 bits for the mantissa
•
4 bits for the exponent
•
two’s complement form for both the mantissa and exponent.
(i)
Write the normalised floating-point representation of the following unsigned binary
number using this system.
1011100.011001
Working …
…
…
…
…
Mantissa
Exponent
[2]
(ii)
State the consequence of storing the binary number in part (a)(i) as a floating-point
number in this system. Justify your answer.
Consequence …
…
Justification …
…
…
[2]
(b) Explain the reason why binary numbers are stored in normalised form.
…
…
…
…
…
…
… [3]

57
9618/31/O/N/21 · Question 3Oct/Nov 2021Paper 314 marks
Loading question…
Question text

3
Enumerated and pointer are two non-composite data types.
(a) Write pseudocode to create an enumerated type called Parts to include these parts sold in
a computer shop:
Monitor, CPU, SSD, HDD, LaserPrinter, Keyboard, Mouse
…
…
… [2]
(b) Write pseudocode to create a pointer type called SelectParts that will reference the
memory location in which the current part name is stored.
…
…
… [2]

58
9618/31/O/N/21 · Question 5Oct/Nov 2021Paper 316 marks
Loading question…
Question text

5
(a) Compare sequential and serial methods of file organisation.
…
…
…
…
…
…
…
…
… [4]
(b) State the most suitable method of file access when a record is referenced by a unique
address on a disk-type storage medium.
… [1]
(c) State the most suitable method of file access when a bank stores its data records in ascending
order of account number.
… [1]

Advertisement
59
9618/31/M/J/21 · Question 1May/June 2021Paper 3114 marks
Loading question…
Question text

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]
(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.
…
…

60
9618/31/M/J/21 · Question 2May/June 2021Paper 318 marks
Loading question…
Question text

2
(a) Describe the purpose of a user-defined data type.
…
…
…
…
… [2]
(b) Define, using pseudocode, the following enumerated data types:
(i)
SchoolDay to hold data about the days students are usually in school.
…
… [1]
(ii)
WeekEnd to hold data about the days that are not school days.
…
… [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).
…
…
…
…
…
…
…
… [4]

Advertisement