Data Representation Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is the purpose of a user-defined data type?

A

-To create a new data type.
-To allow data types not available in a programming language to be constructed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Why user-defined data types necessary?

A

-No suitable data type is provided by the language used.
-The programmer needs to specify a new data type
…that meets the requirement of the application

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is meant by a user defined data type?

A

-Derived from on or more existing data types.
-Used to extend the built-in data types.
-Creates data types specific to applications.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Define a non-composite data type.

A

A data type defined without reference to another data type.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Define enumerated data type.

A

A data type that has an ordered list of possible values.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Define a data type that holds the set of prime numbers below 20.

A

TYPE Prime = (2, 3, 5, 7, 11, 13, 17, 19)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Define composite data type.

A

A data type defined with reference to another data type.

Ex:
TYPE User
DECLARE Name : STRING
DECLARE DateOB: DATE
DECLARE Telephone: INTEGER

ENDTYPE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Define pointer data type.

A

A user-defined non-composite data type that points to a memory location.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Declare a data type that points to a day of the week.

A

TYPE TDayPointer = ^STRING // ^DayOfWeek

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Define a set

A

A set is a given list of unordered elements that can use set theory operations such as intersection and union.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Create a set named letter of type char. The declare a variable to hold the vowels of the type of the set.

A

TYPE letter = SET OF CHAR
DEFINE vowel (‘a’, ‘e’, ‘i’, ‘o’, ‘u’) : letter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What happens when you want to represent a number that occpuies 10 bits with 8 bits. (2 marks)

A

-Bits have to be truncated in order to represent a number with fewer bits than their starting ones.
-Therefore precision is lost.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is underflow?

A

It occurs after an arithmetical/logical operation when the result is too small to be precisely represented in the available system.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Match the files to their corresponding types (sequential, random or serial): “Text file” ;”File for recording temperature every hour” ; “Master file for paying each employee every month”; “Customer user name and password file”

A

Text file (serial)
File for recording temperature every hour(serial)
Master file for paying each employee every month(sequential)
Customer user name and password file(random)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a sequential file (max 5)

A

-In a sequential file records are stored in a particular order.
-The order is determined based on the value in a key field.
-Records are accessed one after the other.
-Records can be found by searching from the beginning of the file record by record
…Until the record is found or key value is exceeded.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What happens when there is a collision in a random access file. (max 9)

A

-A collision occurs when the record key doesn’t match the stored record key.
… this means the storage location has already been used for another record that its’ key hashes to the same value.

If we want to store a record:
-Search the file linearly
… to find the next available file storage (called closed hashing)

-Search the overflow area linearly
… to find the next available file storage (open hashing):

If we want to find a record:
…. search the overflow area linearly until the matching record key is found.
… search the file linearly from where you are until the matching record key is found.
-If record not found record is not in the file

17
Q

When does a collision occur?

A

For there to be a collision the hash value calculated has to be a duplicate of a hash value previously calculated.

18
Q

How are records stored in serial file organisation?

A

Records are stored one after the other, in the order they were added to the file.
-new record appended to the end of the file

19
Q

How are files stored in a random access file?

A

The position of any record in a field is found by applying a hash algorithm on the key field of the record/record key.

20
Q

Why choose a serial file?

A

-Records can be easily added.
-No need to re-sort data to add new data.
-For small files seacrhing will require little processing

21
Q

Describe Sequential access

A

It is a method of file access in which records are searched one after the other from the start or the file. Used for serial and sequential files.

22
Q

Describe direct access

A

Method of file access in which a record can be physically found in a file without reading other records.

23
Q

What happens when the number of bits used for the exponent increases.

A

The range increases.

24
Q

Problems of not normalizing.(max 4)

A

-Loss of precision.
-Redundant leading zeros in the mantissa.
-Lost of the least-significant bits.
-MUltiple representations of a single number.

24
Q

Why are binary numbers normalized (max 8)

A

-To store the maximum range of numbers in the minimum number of bits.
-Normalisation minimises the number of leading zeros/ones represented.
-maximising the number of significant bits.
-Enables large/small numbers to be stored with accuracy.
-Avoids the possibility that many numbers have the same representation.
-There will be a unique representation for a number.
-The format will ensure it will be represented with the greatest possible accuracy.
-Multiplication is performed more accurately.

24
Q

Explain the cause of rounding errors in calculation. (Pregunta random hace falta contexto)

A

-[number] can’t be represented exactly in binary, there is a rounding error.
-It is represented by a number just less/greater.
-Adding/multiplying these representations increases the difference.
-Until it is significant to be seen

25
Q

Why do some binary representations lead to rounding errors?

A

-There’s no exact binary conversion for some numbers.
-More bits are needed to store the number.