language defines range of possible values, and operations for manipulating values
1 of 21
User-defined datatypes
programmer includes definition in program – variables can be assigned this datatype. Can only be used within the program in which it is declared. Used when no built-in datatype is suitable for storing program specific data efficiently
2 of 21
Composite datatype
Non-composite datatype
defined without reference to another datatype. Can only be one value
includes multiple elements and is defined using built-in datatypes or other composite datatypes
3 of 21
Enumerated datatype
Definition includes all possible values
TYPE TSeason = (Spring, Summer, Autmn, Winter) // not string values
DECLARE Season1 : Season
Season1 <- Spring
IF Season1 > Summer THEN… // Implied order of values
4 of 21
Record
collection of elements, each with a value (can be different datatypes and user-defined or built in). Related data can be access with one construct.
5 of 21
Pointer
value is reference to memory address of other variable
6 of 21
Set datatype
collection of data items with no structure, no duplicate data and defined mathematical operations
Union (∪): set of all elements in collection of sets
Intersection (∩): set of all elements in all sets
Difference (\): set of all element in A that are not m
7 of 21
Binary file
file for storing data to be input by and output to a computer program
Record: collection of fields containing data values
Number of fields per record defined
Data stored using its internal representation (e.g. two’s complement for integers)
8 of 21
Text file
file containing sequence of characters formatted into lines. Each character is represented in the computer by a character code.
9 of 21
Serial file
records have no defined order – new records appended to end of file.
10 of 21
Sequential files
read from start, previous records must be accessed before next one can be read. Records are stored in a particular order according to a key field value, which must be unique and sequential. E.g. file of payment transactions
11 of 21
Direct-access file
records have defined order and position – uses key field values. Any record can be accessed directly without accessing previous records. E.g. database
12 of 21
Uses of sequential access
Uses of direct access
store data temporarily as it becomes available, with intention of processing every record; multiple records in one search
long term storage for when data changes continuously; fast access to individual records
13 of 21
Hashing algorithm
input key field value of any size
output shorter, fixed-length value
output values have no order depending on input value
14 of 21
Hashing Collision
when different input values produce same output value.
hashing algorithm should distribute output values evenly to avoid collisions.
must be defined rules for dealing with collisions.
15 of 21
Prime Divisors
better as if same key values used more often, non-primes may have factors that are factors of key values too, so collision more likely
16 of 21
Fixed-point representation
total bits chosen with defined number of bits for whole and fractional part
Sign bit-2^5, 2^4, 2^3, 2^2, 2^1, 2^0.2^-1, 2^-2
17 of 21
Floating-point representation
values for mantissa and exponent chosen
mantissa = value, exponent = magnitude
± M x R^E (R has implied value of 2)
Binary point should always be after sign bit
18 of 21
Floating-point range vs precision
increasing bits for mantissa increases precision
increasing bits for exponent increases range
19 of 21
Normalisation
Process of ensuring every number in floating-point binary has only one representation
Positive: bits in mantissa shifted left (x2) until MSBs are 0 and 1 - while exponent is decremented by 1 (%2)
Negative: bits in mantissa shifted left until MSBs are 1
20 of 21
Problems with floating-point representation
Round errors: denary numbers cannot be represented exactly, so approximation is made - may become significant for repeated calculations
Overflow/Underflow error: calculation produces number which is too big/small to be stored using current representation
21 of 21
Other cards in this set
Card 2
Front
User-defined datatypes
Back
programmer includes definition in program – variables can be assigned this datatype. Can only be used within the program in which it is declared. Used when no built-in datatype is suitable for storing program specific data efficiently
Comments
No comments have yet been made