user-defined types
derived from one or more existing datatypes
used to extend the built-in datatypes
programmer’s requirement
why are user-defined types necessary
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
composite data types
data types constructed from other types
e.g: record, list, set, array, class, queue, linked list, dictionary
non-composite
datatype that does not refer to another datatype
e.g: enumerated, pointer, real, string, char, boolean
enumerated
non-composite
defines an ordered list of all possible values
enumerated TYPE pseudocode declaration
the values do not need any speech marks etc.
TYPE identifier = (value1, value2, …)
pointer
non-composite
used to reference a memory location
pointer TYPE pseudocode declaration
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
set
stores groups of values and supports mathematical operations
record
composite
collection of related items with multiple datatypes
a fixed number of components
allows the user to collect values with different data types together.
list
indexed collection that can contain different datatypes
array
indexed collection of items of the same datatype
serial file organization
when is serial used?
sequential file organization
when is sequential used?
random/direct file organization
what happens if a collision occurs in direct access
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
hashing algorithm
a mathematical function to find a hash key to access data
sequential access
direct access
value in key field is submitted to hashing algorithm which provides position used at data input
twos complement
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
format of binary floating point
plus or minus M x 2^E
M = mantissa
E = exponent
more bits in mantissa = more accurate
more bits in exponent = larger range
normalisation rules
for positives, shift left until it starts with a 01
for negatives, shift left until it starts with a 10