Chapter 13: Data Representation Flashcards

(24 cards)

1
Q

Composite Data Type

A

-single data type that is referenced from other data type
- Data type can be primitive or user-defined
- Record : a collection related items that have different data types
- Array : indexed collection of items with same data type
- List : indexed collection of items that can have different data types
- Class : gives the properties and methods for an object

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

Non-composite data type

A
  • Single data type that does not involve a reference to another data type
  • Usually built in to a programming language.
  • Integer : stores a whole number
  • Boolean : stores true or false
  • Real : stores decimal number
  • String : stores one or more character
  • Pointer : whole number used to reference a memory location
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Enumerated data type

A
  • a user-defined non-composite data type with an ordered list of possible values
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Pointer data type

A
  • a user-defined non-composite data type used to reference a memory location
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Why need user-defined data type ?

A
  • no suitable data type is provided in language used
  • Programmer need to specify new data type
  • Referenced from one or more existing data type
  • Extend the built-in data types
  • That meet requirements of application
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Changes of Mantissa/Exponent

A

More bits for mantissa - better precision
More bits for exponent - larger range

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

Why some binary representation lead to rounding errors ?

A
  • some number cannot be represented by exact binary number
  • More number of bits than available is needed to store the number
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Problems occur due to change in the representation of floating-point number

A
  • number calculated will change
  • many numbers having same representation
  • software may clash if not updated
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Why floating point number is normalised?

A
  • first 2 bits is opposite
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Why binary numbers are stored in normalized form ?

A
  • store maximum range of number in minimum number of bytes
  • Minimise num of leading zero represented
  • Maximising precision of the number for the given number of bits
  • Enable very large/small number to be stored with accuracy
  • Avoids possibility of many numbers having same representation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Problem occur when floating point number are not normalised

A
  • Precision lost
  • Redundant leading zeros in mantissa
  • Bits loss off right hand end
  • Multiple representation of a single number
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Overflow

A
  • occur in exponent of a floating-point number
  • Exponent become too large to be represented using the number of bits available.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Underflow

A
  • Following an arithmetic/logical operation
  • number too small
  • Cannot be represented by the number of bits available
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Sequential

A

sequential

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

Random

A

direct

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

Serial

A

direct/sequential

16
Q

Why serial file organisation ?

A
  • high hit rate
  • records are stored in chronological order
  • Easy to append new record to EOF
  • Allows reading of records in the order that they were taken
  • No key fields need to be added
  • No need sort data every time new data is added (order not important)
  • Only a small file so searching only require a little processing
17
Q

Why sequential file organisation ?

A
  • high hit rate
  • has key field to be used
  • Data can be sorted
  • Suitable for batch processing
18
Q

Why serial file organisation use sequential access ?

A

– earliest record is accessed first
- And each successive records is read
- Until final reading has been accessed

19
Q

Compare serial and sequential

A
  • Both file records are stored one after the other
  • And need to be accessed one after the other
  • Serial file is stored in chronological order
  • Sequential files are stored in the order of key field
  • And stored in ordered records
  • Serial files, new record is appended to the file
  • Sequential files, new records are inserted in correct position.
20
Q

How random file organisation work

A
  • home locations are calculated
  • Using a hashing algorithm on a key field
  • If home location is free, insert record
  • If a record cannot be stored at that location
  • Then subsequent locations are searched
  • Or use overflow method to find free location to store record
  • If no free location available then record cannot be stored
21
Q

How random file organisation’s record is found

A
  • key field is hashed to get home location
  • Compared ID to the home location
  • If nothing stored, output msg “record not found”
  • Record ID equal, record is found
  • Record ID not equal, search overflow area
  • Until record found or whole area searched
  • If no record found error msg
22
Q

Why random file organisation is appropriate

A
  • Low hit rate
  • speed of access
  • No need search through all records
  • Suitable for access to single record - Just used as a look up file
  • No need for any serial or sequential processing
23
Q

Describe the user-defined data type record

A
  • A user-defined record is a composite data type
  • It uses other data types in its definition to form a single new data type
  • Data types are referenced may be primitive from a programming language/they may be other user-defined data type
  • Include related items
  • Include fixed number of items.