0% found this document useful (0 votes)
19 views2 pages

User Defined

The document describes user-defined data types, requiring declarations for a set of prime numbers below 20 and a type for days of the week. It also explains a hashing algorithm that calculates storage locations for records in a random access file using modulus functions, detailing how to handle duplicate hash values. Additionally, it discusses the organization and access of records in sequential files.

Uploaded by

masunda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views2 pages

User Defined

The document describes user-defined data types, requiring declarations for a set of prime numbers below 20 and a type for days of the week. It also explains a hashing algorithm that calculates storage locations for records in a random access file using modulus functions, detailing how to handle duplicate hash values. Additionally, it discusses the organization and access of records in sequential files.

Uploaded by

masunda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

User defined data types

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]

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]

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]

You might also like