Number 1

Data Representation


Why use User Defined Data Types (UDDTs)?

  • To group a specific set of related data under a single identifier

  • Make program code clearer and easier to read/maintain

  • To produce a data structure that precisely matches the requirements of a real-world problem


Non Composite VS Composite

Classification

Definition

Examples

Non-Composite

A data type defined without referencing any other data type. It contains only a single data type in its definition[4]. Can be primitive or user-defined[4][5].

Primitive: INTEGER, REAL, STRING, BOOLEAN, CHAR, DATE
User-Defined: Enumerated, Pointer

Composite

A user-defined data type constructed by referencing or combining other data types (primitive or user-defined) under a single identifier[4].

Record, Set, Class / Object


Non Composite:

- Enumerated

  • A non composite user defined data type consisting of an ordered list containing all possible values for a variable

  • Key Features:

  • Ordered - elements exist in a specific sequence

  • Unique elements - no repeat or duplicate values permitted

  • All items on the list belong to the same data type

  • Pseudocode example:

  • TYPE Spectrum = (Red, Orange, Yellow, Green, Blue, Indigo, Violet)

- Pointer

  • A non composite user defined data type used to store and reference a memory address while indicating the data type stored at that location    

  • Pseudocode example:

  • TYPE Word = ^STRING


Composite

- Record

  • A composite data type that combines a fixed number of related items/fields, which can be of different data types, under a single identifier

  • Pseudocode example:

  • TYPE BookingRecord

                 DECLARE BookingID : STRING

                 DECLARE SeatNumber : 1 .. 12 // 1 to 12 inclusive

  • DECLARE CurrentBooking : BookingRecord

- Set

  • A composite data type consisting of an unordered collection of unique elements of the same data type with supports mathematical set theory (Union, Internsection)

  • Pseudocode example:

  • TYPE SymbolSet = SET OF CHAR

  • DEFINE Operators (‘+’, ‘-’, ‘/’, ‘*’) : SymbolSet

- Class

  • Encapsulates both properties/attributes and methods/procedures/functions with a single object structure



File Organisations

File Organisation

Record Arrangement

File Access Methods

Typical Exam Examples / Use Cases

Serial

Stored one after another in chronological order (order of arrival). New records are appended to the end.

Sequential Access: Must read linearly from the physical start of the file record-by-record until found or EOF.

Unsorted transaction files, batch transaction files, data logging files

Sequential

Stored one after another in a specific ordered sequence based on a key field. Updating requires writing a new file version

Sequential Access: Read linearly from start; search stops when key is found, EOF reached, or key value exceeded.
Direct Access: Uses an index of key fields to find physical addresses.

Batch processing (payroll, utility billing), backups.

Random

Stored in no particular order / occupies any available slot. Record location is calculated via a hashing algorithm on the key field. Records updated in place.

Direct Access: Applies hashing function directly to target key field to locate address.

Database Management Systems (DBMS), real-time booking platforms (airlines, hotels), video games, OS file managers.


Hashing algorithm:

  • A mathematical formula applied to a record’s key field to generate the physical storage address where the record is stored or retrieved


Collision:

  • Occurs when two distinct record keys generate the exact same hash value after passing through the hashing algorithm. Because two records cannot occupy the same physical address, a collision resolution strategy is required


Collision resolution strategies:

- Linear Probing / Closed hashing:

  • Starts at the calculated hashed space and searches subsequent memory slots linearly/sequentially, placing the record in the first available empty space

- Overflow Area / Open hashing:

  • Stores colliding records in a separate, dedicated overflow area, searching it linearly for the first free space


Process to Find a Record in a Random File:

  1. Direct file access is initiated.

  2. Apply the hashing algorithm to the target record's key field to calculate its storage address

  3. Read the calculated address and inspect the record key

  4. If the key at that location matches the target key, retrieve the record

  5. If the key does not match (indicating a collision occurred during writing), execute the collision strategy

  • Linear Probing: Search linearly from that address onwards until the key is matched

  • Overflow Area: Search the overflow area linearly until the key is matched

  1. If an empty slot is encountered (or end of overflow area is reached) without a match, report record not found


Floating Point:

Reasons for normalisation:

  • Maximum precision - eliminating redundant bits

  • Maximum range - allows representing the largest possible range of numbers in the smallest number of bits

  • Allows for unique representation - prevents multiple representations of same value


Bit Allocation Trade Offs

Increasing Mantissa bits:

  • Increases precision/accuracy of representation

  • Decreases the range of numbers that can be stored

Increasing the Exponent bits:

  • Increases the range of numbers (enable storing very large/small numbers)

  • Decreases precision/accuracy, increasing rounding errors


Error / Issue

Definition / Cause

Exam Explanation Points

Inexact Representation / Rounding Error

Binary fractional positions represent powers of 2

Many denary decimals cannot be represented as exact sums of powers of 2. Storing them causes truncation/loss of least significant bits.

Overflow

Occurs when an arithmetic operation produces a value greater than the maximum representable value.

The calculated value exceeds the capacity of the exponent bits; most significant bits are lost.

Underflow

Occurs when an arithmetic operation produces a result too small / too close to zero to be stored.

The required negative exponent is too small/negative for the allocated exponent bits; the result becomes zero.



Communication and Internet Technologies


Protocol:

  • A standard set of rules for communication between the computer systems

- Why are they essential?

  • Estabilishing standards - sets a mandatory set of rules for transferring data across networks

  • Ensures compatibility - enables communication and compatibility between hardware and software platforms from different manufacturers

  • Makes network communications independent of specific hardware/software

  • Without protocols, 2 devices using different rules wouldn’t be able to transmit or interpret messages


Layer Order

TCP/IP Layer Name

Layer 4

Application Layer

Layer 3

Transport Layer

Layer 2

Internet Layer (Network Layer)

Layer 1

Link Layer (Network Access Interface)

Each layer only interacts with the layers above/below it


Outgoing transmission (Top to Bottom):

  • The user/application software interfaces with the application layer at the top. As data moves down the stack, each layer adds its own header information before handing it off to the lower layer


Incoming transmission (Bottom to Top):

  • When receiving data, frames are accepted by the Link Layer and passed upwards through adjacent layers, stripping headers until reaching the application layer


1. Application Layer
  • Primary Purpose: Provides user services and programs (such as web browsers or email clients) access to network transmission capabilities

  • Key Functions:

    • Defines protocols used by applications to exchange data across networks

    • Interacts directly with user-level software applications

    • Provides mechanisms for securing communications (such as encryption and authentication)

    • Handles application-specific error detection and recovery

2. Transport Layer
  • Primary Purpose: Responsible for logical end-to-end, error-free delivery of data between applications running on source and destination hosts

  • Key Functions:

    • Segmentation & Reassembly: Breaks outgoing data into smaller segments/packets and reconstructs them at the destination

    • Sequence Control: Adds sequence numbers to packet headers to reorder arriving packets into the correct sequence

    • Error & Flow Control: Provides flow control mechanisms to regulate connections and prevent data loss, using checksums and Automatic Repeat Requests (ARQ) to retransmit corrupted or lost packets

3. Internet Layer
  • Primary Purpose: Identifies the intended network and host, formatting data into datagrams and routing them across intermediate networks

  • Key Functions:

    • IP Addressing: Attaches headers containing source and destination IP addresses to packets

    • Routing: Determines the optimum independent route for datagrams across the network

    • Sockets: Combines an IP address with a port number to create a socket for targeted host-process addressing

4. Link Layer
  • Primary Purpose: Manages links between directly connected physical nodes on local network segments and interfaces directly with transmission hardware

  • Key Functions:

    • Framing: Formats datagrams into physical frames for transmission

    • Address Resolution: Maps logical IP addresses to physical MAC addresses

    • Physical Media Control: Handles physical transmission error checking, correction, and hardware protocol adherence


Application Layer Protocols Reference Guide

  • HTTP / HTTPS (Hypertext Transfer Protocol / Secure):

    • Purpose: Used for transferring web pages, hypermedia documents, images, and data files securely between web servers and client browsers over the World Wide Web

  • FTP (File Transfer Protocol):

    • Purpose: Used for interactive uploading, downloading, and transferring files between client and server locations on a network

  • SMTP (Simple Mail Transfer Protocol):

    • Type: Push protocol

    • Purpose: Used for sending email messages from a client computer to a mail server, or transferring emails between mail servers

  • POP3 (Post Office Protocol 3):

    • Type: Pull protocol

    • Purpose: Used for downloading/retrieving emails from a mail server to a local client computer (typically removes messages from the server upon download)

  • IMAP (Internet Message Access Protocol):

    • Type: Pull protocol

    • Purpose: Used for retrieving and reading emails from a mail server while synchronizing messages across multiple devices without removing them from the server


BitTorrent Protocol

  • Network Model: Peer-to-Peer (P2P) network model where all connected user computers act as peers of equal status without relying on a central web server

  • Key Definitions & Components:

    • Torrent Descriptor File: A small file containing metadata about the file to be shared

    • Swarm: The group of connected computers simultaneously sharing and downloading pieces of a file

    • Tracker: A central server that maintains records and IP addresses of all computers in the swarm to help them connect

    • Seed: A peer that possesses a complete copy of the file and continues uploading it to others

    • Leech: A peer that downloads significantly more data than it uploads

  • Operational Process:

    1. The target file is split into small, equal-sized pieces

    2. A peer downloads the torrent descriptor file and connects to the tracker.

    3. The tracker shares the IP addresses of other peers in the swarm.

    4. Peers simultaneously download missing pieces from multiple peers while uploading received pieces to others

    5. Once a peer completes the full file download, it becomes a seed


Transport Layer Security (TLS)

TLS relies on two distinct protocols to secure network communications:

  1. Handshake Protocol: Establishes a secure and reliable connection between devices by authenticating the client and server and negotiating encryption algorithms

  2. Record Protocol: Encrypts and authenticates application data, managing transmission formats to preserve confidentiality and message integrity


Transmission Methods: Circuit Switching vs. Packet Switching

Circuit Switching

  • Mechanism: A dedicated physical circuit/channel is established between sender and receiver prior to transmission, maintained throughout the communication, and closed upon completion. Data flows in a continuous stream over a single fixed route

  • Appropriate Uses: Real-time voice calls, live video streaming, or private networks requiring continuous bandwidth

Benefits of Circuit Switching

Drawbacks of Circuit Switching

Guaranteed Bandwidth: Full channel bandwidth is continuously available

Connection Setup Delay: Delays occur while establishing the dedicated link before transfer starts.

Ordered Arrival: Data arrives in exact sending order without requiring reordering.

Inefficient Resource Use: Line cannot be shared with other messages, even if idle.

No Packet Delay: No packet reassembly or intermediate routing waiting times.

No Alternative Rerouting: If a link line fails, the connection immediately drops.

Low Data Loss Risk: Data travels intact along a dedicated path.

Lower Security: Interceptable because all data follows one fixed path.

Packet Switching

  • Mechanism: Messages are divided into small, equal-sized packets. Each packet receives a header containing source/destination IP addresses, packet numbers, etc., and travels independently across dynamic optimum routes. Packets arriving out of order are reassembled at the destination.

  • Appropriate Uses: General data networks (Internet), email, web pages, and file transfers where connection resilience and line sharing are needed.

Benefits of Packet Switching

Drawbacks of Packet Switching

Shared Bandwidth: Channel bandwidth can be shared simultaneously among multiple users.

Reassembly Latency: Delays occur while reordering and reassembling packets at the destination.

High Resilience: Packets are dynamically rerouted around congested or faulty network lines.

Retransmission Delays: Waiting for re-sent missing or damaged packets introduces latency.

Targeted Resending: Only missing or corrupted individual packets need to be retransmitted.

Complex Hardware/Protocols: Requires complex routing algorithms and large RAM buffers at routers.

Enhanced Security: Harder to intercept because packets travel over varying routes.

Unsuitable for Real-Time: Latency makes it poor for real-time live streaming applications.


Router Mechanics & Error Recovery in Packet Switching

Function of a Router

  1. Header Inspection: Examines arriving packet headers to extract destination IP addresses.

  2. Routing Table Consultation: Consults an internal routing table containing netmasks, gateways, adjacent routers, and line statuses

  3. Route Determination: Determines the optimum next hop or best path based on network traffic and congestion

  4. Hop Counter Management: Decrements the packet's hop counter (TTL) by 1 at each router pass

  5. Forwarding: Dispatches the packet to its next intermediate hop

Error Recovery & Completeness

  • Re-send Requests: The destination host checks arriving packets for damage or missing sequence numbers. If a packet is missing or corrupted, a re-send request is generated

  • Hop Count Expiry: If a packet's hop count is decremented to zero, the packet is retired/dropped to prevent infinite loops, which triggers a re-send request