Data Representation

User defined-data types:

It is a custom data structure designed by a programmer to match the requirements of a program.



Non-composite type -

  • Enumerated

    • It is where an identifier can hold a limited number of values {e.g: the days of the week.}

    • Mainly used for readability, validation, reduced errors and predefined values.

  • Pointer

    • A pointer is like a piece of paper that contains the address of a house.

    • The paper is the not the house itself but give an address to locate the house.

    • Type inrpointer = ^interger

    • p ; inrpointer

    • x ← 50

    • p ← @x

    • Pointers are used for memory efficiency, linked list and stack/queues.


Composite Type -

  • record

    • Have multiple fields of different data types.


  • Sets

    • A composite data type used when duplication is not allowed.

    • Order is not important

    • Can perform operation such as union, intersection and difference.


File Organisation & Access -

File Organisation:

  • The way files are organised for quick retrieval, updates and deletion.

  • The ways records are arranged is called the file’s organisation method.

  • File organisation methods:

    • Serial

      • records that are stored in the order that they arrived.

        • Simple, but difficult to search.

    • Sequential

      • Records are stored in a sorted order based on their field key.

        • More efficient to search and used for records that are rarely updated.

    • Direct (random)

      • Records that are sorted in a specific location using a hashing algorithm.

        • Very fast and reliable to search.


What is a hashing algorithm?

An algorithm used to calculate the location (address) where the record is going to be stored.

  • Used for faster access

  • Mainly used when it involves a large amount of records and data.

  • Used in random files and sometime in sequential files.


Types of Hashing Algorithm:

  • Modulo Division

  • Folding mehtod.

    • the key is broken in to pieces and added together.

  • Mid-square method    

    • Squares the key and use the middle digit as the address.

  • Multiplicative hashing

    • Multiplies the key by a constant and uses fractional parts.


Collision Handling Strategies:


Floating-point Numbers, representation and Manipulation -

Floating point Binary:

  • Used to represent real numbers using binary, including fractions and very large or small values.

  • Utilises limited storage.

  • More precision


Conversion:



Approximation & Rounding