File Organisation & Access (Cambridge (CIE) A Level Computer Science): Exam Questions

Exam code: 9618

32 mins7 questions
12 marks

A program is being developed to implement a game for up to six players.

During the game, each player assembles a team of characters. At the start of the game there are 45 characters available.

Each character has four attributes, as follows:

Attribute

Examples

Comment

Player

0, 1, 3

The player the character is assigned to.

Role

Builder, Teacher, Doctor

The job that the character will perform in the game.

Name

Bill, Lee, Farah, Mo

The name of the character. Several characters may perform the same role, but they will each have a unique name.

Level

14, 23, 76

The skill level of the character. An integer in the range 0 to 100 inclusive.

The programmer has defined a record type to define each character.

The record type definition is shown in pseudocode as follows:

TYPE CharacterType
DECLARE Player : INTEGER
DECLARE Role : STRING
DECLARE Name : STRING
DECLARE Level : INTEGER
ENDTYPE

The Player field indicates the player to which the character is assigned (1 to 6). The field value is 0 if the character is not assigned to any player.

The programmer has defined a global array to store the character data as follows:

DECLARE Character : ARRAY[1:45] OF CharacterType

At the start of the game all record fields are initialised, and all Player field values are set to 0

The programmer has defined a program module as follows:

Module

Description

Assign()

  • called with two parameters:  

    • an integer representing a player  

    • a string representing a character role

  • search the Character array for an unassigned character with the required role

  • If found, assign the character to the given player and output a confirmation message, for example:  "Bill the Builder has been assigned to player 3"

  • If no unassigned character with the required role is found, output a suitable message.

The save operation is to be extended so that multiple files may be saved as the game progresses. This will allow the user to restore the game from any saved position. The filename must reflect the sequence in which the files are saved.

Describe a method that would allow multiple files to be saved and give an example of two consecutive filenames.

2a3 marks

Explain what is meant by a hashing algorithm in the context of file access.

2b2 marks

The use of a hashing algorithm can result in the same storage location being identified for more than one record.

Outline two methods of overcoming this issue.

3a2 marks

Describe serial file organisation as a method of storing data records in a file.

3b1 mark

State one example of a use for serial file organisation.

4a2 marks

Describe the sequential method of file access.

4b3 marks

Explain how the sequential method of file access is applied to files with serial organisation and to files with sequential organisation.

5a2 marks

Outline what is meant by direct access as a method of file access.

5b4 marks

Explain how direct access is used to locate a specific record in sequential files and random files.

(i) Sequential files

(2)

(ii) Random files

(2)

6a4 marks

Describe sequential and random methods of file organisation.

6b2 marks

Outline the process of sequential access for serial and sequential files.

7a2 marks

The location of a record in a random file is determined using a hashing algorithm. A collision may occur during the process of adding a record.

Outline what is meant by the term collision in this context.

7b3 marks

Explain how a collision can be dealt with when writing records to a random file.