Chapter 13 Flashcards

"Data Representation"

1
Q

user-defined types

A

derived from one or more existing datatypes
used to extend the built-in datatypes
programmer’s requirement

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

why are user-defined types necessary

A

if no suitable datatype is provided by the language used
to provide more flexibility
if a programmer needs a specific datatype/needs to create a new data type
that meets program requirements

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

composite data types

A

data types constructed from other types
e.g: record, list, set, array, class, queue, linked list, dictionary

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

non-composite

A

datatype that does not refer to another datatype
e.g: enumerated, pointer, real, string, char, boolean

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

enumerated

A

non-composite
defines an ordered list of all possible values

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

enumerated TYPE pseudocode declaration

A

the values do not need any speech marks etc.

TYPE identifier = (value1, value2, …)

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

pointer

A

non-composite
used to reference a memory location

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

pointer TYPE pseudocode declaration

A

this is a declaration of the TYPE, not of the variable. if you wish to declare a variable of this pointer type:

TYPE pointerTypeName = ^DATATYPE

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

set

A

stores groups of values and supports mathematical operations

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

record

A

composite
collection of related items with multiple datatypes
a fixed number of components
allows the user to collect values with different data types together.

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

list

A

indexed collection that can contain different datatypes

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

array

A

indexed collection of items of the same datatype

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

serial file organization

A
  • data is stored in chronological order (no predefined order)
  • data is appended to the end of the file - into the next available space
  • (easy to add)
  • records need to be accessed one after the other
  • allows the data to be read in order of when they were taken
    no KEY FIELDS need to be added
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

when is serial used?

A
  • when chronological order matters
  • when wanting to append records
  • small file, so easy to search
  • when re-organizing as re-sorting is not required
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

sequential file organization

A
  • records are stored in a predefined order (particular order), stored in the order of the value in the key field
  • new records are inserted in the correct position
  • a new version of the file has to be created to update the file
  • records need to be accessed one after the other
  • records can be found by searching from the beginning of the file,
  • record by record, until the required record is found or key field value is exceeded.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

when is sequential used?

A
  • when there are unique fields, so it can be used for indexing
  • when it needs to be sorted in an order
17
Q

random/direct file organization

A
  • records are stored in no particular order
  • record location is calculated
  • using a hashing algorithm on a key field
  • speed of data access is increased
  • can be used as lookup file
  • ** updates to the file can be carried out directly**
18
Q

what happens if a collision occurs in direct access

A

A collision occurs when the record location is taken.
the location from the hashed key field is in use for another record.

If the record is to be stored
* Search the file linearly
* … to find the next available storage space (closed hash)
* Search the overflow area linearly
* … to find next available storage space (open hash)

If the record is to be found
* … search the overflow area linearly
* … search linearly from where you are
* If not found record is not in file

19
Q

hashing algorithm

A

a mathematical function to find a hash key to access data

20
Q

sequential access

A
  • searches from the beginning of the file
  • checks records linearly (record by record)
  • until the record is found or its the end of the file (key field value is exceeded)
21
Q

direct access

A

value in key field is submitted to hashing algorithm which provides position used at data input

22
Q

twos complement

A

start from the right side and copy down every digit until you encounter a 1
copy down the 1, and then flip all the rest of the bits after the 1

23
Q

format of binary floating point

A

plus or minus M x 2^E
M = mantissa
E = exponent

more bits in mantissa = more accurate
more bits in exponent = larger range

24
Q

normalisation rules

A

for positives, shift left until it starts with a 01
for negatives, shift left until it starts with a 10

25
Q

normalisation advantages

A
  • unique representation for each number
  • minimise leading zeroes/ones
  • ensures number is as accurate as possible
  • store max. range in min. bits
  • maximises number of significant bits - can store very large or small numbers accurately
  • multiplication is more accurate and precise
26
Q

example q from past paper, answer generically: explain the reason why the normalised form of this binary number cannot be represented accurately using this system

A
  • The least significant digits would be truncated
  • …causing a loss of precision/accuracy
  • the mantissa of the number would need to be X bits / digits
  • …however it can only store X bits / digits
  • BE SPECIFIC
27
Q

convert floating point to denary

A
  • if negative (starts with a 1), apply twos complement
  • move the mantissa decimal point (from between the first two bits) to the right, by the exponent value
  • convert by labelling integer digits with 1,2,4,8 etc and the decimal parts with 1/2, 1/4, 1/8, etc

show the working out of the exponent e.g. exponent = X
show the working out of the mantissa e.g. the moving of the decimal, the adding of numbers, etc.
the final answer only gets one mark - SHOW WORKING OUT

28
Q

convert denary to floating point

A
  • split the number into its whole part and its decimal section.
  • convert each corresponding side into binary
  • fill it into the mantissa (e.g. add extra zeroes to the front if necessary)
  • if the denary number is negative, apply twos complement
  • now move the binary point as far as possible until 1.0 or 0.1 (depending on positive or negative) can be formed (normalise it)
  • however many places it moved up is the exponent

remember to show working out:
of exponent - show the moving of the binary point
of mantissa - show the conversion to binary

29
Q

overflow error

A

answer requires more bits than is available.
number is shortened - less precise/accurate

(remember to be SPECIFIC when questions ask - refer directly to the question)

30
Q

underflow error

A

trying to store a very small number, which is smaller than what you can store with the available bits.
occurs after an arithmetic/logic operation

31
Q

rounding error in floating point

A

no exact binary conversion for some numbers/more bits needed to represent a number than available