13 - data representation Flashcards

1
Q

user defined data type

A

a data type based on an existing data type or other data types that have been defined by a programmer

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

why use user defined data types

A
  • built in types arent sufficient to represent data
  • store data of same or diff types (flexible)
  • can be encapsulated which ensures consistency and uniformity
  • Can be reused
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

non-composite data type

A

a data type that doesnt reference other data types
eg enumerated, pointer

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

enumerated data type

A

non composite data type
defined by a list of all possible values with an implied order
eg TSeasons = (Spring ,Summer, Autumn, Winter)
DECLARE thisSeason : TSeasons
TYPE <identifier> = (value1, value2, value3...)</identifier>

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

pointer data type

A

non composite
references a memory location
TYPE <pointer> = ^<Typename>
eg TYPE TmonthPointer = ^Tmonth
DECLARE monthPointer : TmonthPointer</Typename></pointer>

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

set data type

A

composite
- a list of unordered elements that can use set theory operations eg intersection, union, difference
- Contains values that are not organised
- Cant have duplicate values
TYPE <set> = SET OF <basetype>
DEFINE <identifier> (value1, value2...) : <set>
eg TYPE Sletter = SET OF CHAR
DEFINE vowel ('a', 'e', 'i', 'o', 'u') : letters</set></identifier></basetype></set>

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

composite data type

A

uses multiple built in data types
eg record, class, set

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

record data type

A

TYPE <idenfiier>
DECLARE <identifier> : STRING
....</identifier></idenfiier>

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

class data type

A

composite
includes variables of given data types and methods
an object is defined from a class

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

serial files

A

records of data are stored in a file, one after another, in the order they were added to the file
- new records appended to the end
eg meter readings, customer transactions

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

sequential files

A

records of data are stored in a file, one after another, in a given order (defined by the key field)
eg store all bank transactions

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

random files

A

records of data are stored in a file in any available position
the location of any record in the file is found by using a hashing algorithm on the key field of a record

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

hashing algorithm

A

mathematical formula used to perform a calculation on the key field of the record;
the result of the calculation gives the address where the record should be found

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

hasing collision

A

eg hash is to divide by 100
102 and 202 will give the same remainder so there is a collision
deal with it by:
- open hash - using the next free space
- closed hash - using the next free space in a give pre set up overflow area
when reading records if key fields dont match when the hash is calculated then all following records need to be read or the overflow area needs to be searches

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

sequential access

A

records are searched one after another
from the physical start of the file until the required record is found
- used when every record needs to be processed

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

direct access

A

a record can be physically found in a file without physically reading other records
- used to find records quickly when an individual record needs to be processed
use hashing or index table

17
Q

file access

A

the method used to physically find a record in the file.
- sequential
- random

18
Q

mantissa

A

fractional part of floating point num

19
Q

exponent

A

the power of 2 that the mantissa is raised to

20
Q

binary floating point number

A

a binary number in the form M*2^E
M- mantissa
E - exponent

21
Q

overflow

A

the result of carrying out a calculation which produces a value too large for the computer’s allocated word size

22
Q

underflow

A

the result of carrying out a calculation which produces a value too small for the computer’s allocated word size.

23
Q

converting to floating point

A

convert to binary
shift to have 1.0 or 0.1 (mantissa)
exponent = amount shifted by

to convert back take exponent and convert - shift by that amount
then convert mantissa to denary

24
Q

fixed point number

A
  • overall number of bits chosen with a defined number for the whole part + remainder for fractional part
  • MSB for sign, next 5 for whole number, last two for fractional part
  • Eg 011111.11 = 37.75 - largest possible value
    Eg 000000.01 = 0.01 0.25 - smallest positive value
25
Q

rounding errors

A

some numbers can only be represented as an approximate value (accuracy of which determined by no. b in mantissa)
eg 0.1 will lead to a rounding error has its impossible to convert
reduce error by increasing size of mantissa
if you add rounded numbers it increases the error

26
Q

normalisation

A

for a + num mantissa starts with 0.1
for a - num mantissa starts with 1.0

27
Q

accuracy and range of numbers

A

accuracy is increases by increasing no b for mantissa
range of numbers is increases by increasing no b for exponent
both these increase storage needed

28
Q
A
28
Q

max/ min numbers using 8b 8b (when normalised)

A

max positive
01111111 01111111
min positive
01000000 10000000
min negative
10111111 10000000
max negative
10000000 01111111