Data Representation

Computers understand only one language: binary, a series of 0s and 1s. All information, from simple numbers to complex videos, must be translated into this binary format.

This section covers:

  • Different number systems (binary, denary, hexadecimal)
  • How computers represent complex data like text, sound, and images
  • Efficient data storage and compression techniques

1.1 Number Systems

Why Binary?

Computers use binary (0s and 1s) because electronic circuits have two states: on/off.

Three Number Systems:

  • Denary (Base 10): 0-9 digits, each position represents a power of 10.
  • Binary (Base 2): 0-1 digits, each position represents a power of 2.
  • Hexadecimal (Base 16): 0-9 and A-F symbols. Each hex digit represents four binary digits (a nibble).

Conversions (Know all directions):

  • Denary Binary Hexadecimal
  • Binary to Hex: Group binary digits into nibbles (4 bits), then convert each nibble.
  • Hex to Binary: Convert each hex digit to its 4-bit binary equivalent.

Why Hexadecimal?

  • Shorter representation than binary.
  • Easier for humans to read and write.
  • Used in:
  • Memory Addresses: To specify locations in computer memory.
  • Color Codes: In web design and graphics (e.g., #FFFFFF).
  • MAC Addresses: Unique identifiers for network interfaces.
  • Error Codes: Often used in system error messages.

Binary Addition (8-bit positive integers):

  • 0 + 0 = 0
  • 0 + 1 = 1
  • 1 + 0 = 1
  • 1 + 1 = 0 (carry 1 to the next column)

Example: 00000011 (3) + 00000101 (5) = 00001000 (8)

Overflow:

  • Occurs when the result of a binary addition exceeds the maximum value for the allocated bits (e.g., >255 in 8-bit).
  • Most significant bits are lost, leading to an incorrect result.

Logical Binary Shifts:

  • Left Shift: Multiplies by 2. A 0 is inserted at the rightmost position.
  • Right Shift: Divides by 2 (integer division). A 0 is inserted at the leftmost position (for positive numbers).
  • Bits shifted off the end are lost.

Two's Complement (8-bit signed integers):

  • Range: -128 to +127.
  • MSB (leftmost bit) indicates the sign: 0 for positive, 1 for negative.
  • To find a negative number:
  1. Take the positive equivalent in binary.
  1. Invert all bits (0s to 1s, 1s to 0s).
  1. Add 1 to the result.

Example: -5 in 8-bit two's complement is 11111011.

1.2 Text, Sound and Images

Text Representation

Text → Binary for processing

  • Character Sets:
  • ASCII: 7-8 bits, 128-256 characters (English only)
  • Unicode: 16-32 bits, 1+ million characters (all languages, emojis)

Unicode needs more bits but supports more characters

Sound Representation

Sound waves → Sampled → Binary

  • Key Factors:
  • Sample Rate: Samples per second (e.g., 44,100 Hz)
  • Sample Resolution (Bit Depth): Bits per sample (e.g., 16-bit)

Effect: Higher rate/resolution = Better quality + Larger file size

Image Representation

Images → Grid of pixels → Binary

  • Key Factors:
  • Resolution: Number of pixels (e.g., 1920×1080)
  • Color Depth: Bits per pixel (e.g., 24-bit = 16.7M colors)

Effect: Higher resolution/depth = Better quality + Larger file size

Exam Tip: Remember the trade-off: Quality ↑ = File Size ↑

1.3 Data Storage and Compression

Data Storage Units (Powers of 2)

  • Bit: 0 or 1
  • Nibble: 4 bits
  • Byte: 8 bits
  • KiB: 1024 bytes
  • MiB: 1024 KiB
  • GiB: 1024 MiB
  • TiB: 1024 GiB
  • PiB: 1024 TiB
  • EiB: 1024 PiB

⚠️ EXAM RULE: Always use 1024, NOT 1000

File Size Calculations

  • Image: Width × Height × Color Depth (bits) ÷ 8 = bytes
  • Sound: Sample Rate × Bit Depth × Length (seconds) × Channels ÷ 8 = bytes

Convert to required units (KiB, MiB, etc.)

Why Compress?

  • ✓ Smaller file size
  • ✓ Less storage needed
  • ✓ Faster transmission
  • ✓ Less bandwidth used

Compression Types

LOSSY (Permanent data loss)

  • Removes data to reduce size
  • Cannot restore original
  • Smaller files, lower quality
  • Examples: JPEG, MP3, MPEG
  • Use: Photos, music, video (where quality loss acceptable)

LOSSLESS (No data loss)

  • Reduces size without losing data
  • Can restore original perfectly
  • Larger than lossy, smaller than original
  • Examples: PNG, ZIP, FLAC, RLE (Run Length Encoding)
  • Use: Text files, programs, medical images (where accuracy essential)

Exam Tip: Know when to use each type!

Programming & Algorithms

This section covers Paper 2 content for your computer science studies.

You will delve into the fundamentals of algorithm design, core programming concepts, database management, and essential Boolean logic.

Key topics include:

  • Algorithm Design & Problem-Solving
  • Programming Concepts & Techniques
  • Databases & SQL
  • Boolean Logic & Logic Circuits

7. Algorithm Design & Problem-Solving

Program Development Life Cycle

  • Analysis: Identify problem, requirements, decomposition, abstraction
  • Design: Structure diagrams, flowcharts, pseudocode
  • Coding: Write and iteratively test code
  • Testing: Test with test data

Decomposition & Design Methods

Decomposition: Breaking problems into: Inputs → Processes → Outputs → Storage

  • Structure diagrams
  • Flowcharts (use standard symbols)
  • Pseudocode

Standard Algorithms (Know these!)

  • Linear search
  • Bubble sort
  • Totalling
  • Counting
  • Finding max/min/average

Validation vs Verification

Validation: Checks data is reasonable/sensible (range, length, type, presence, format, check digit)

Verification: Checks data is accurate (visual check, double entry)

Test Data Types

  • Normal: Valid, expected input
  • Abnormal: Invalid, should be rejected
  • Extreme: Valid, at limits (largest/smallest acceptable)
  • Boundary: At edge of valid range (test both sides)

Trace Tables

Document dry-run of algorithm

Track: variables, outputs, user prompts at each step

Exam Skills

  • Identify errors in algorithms
  • Write/amend algorithms in pseudocode/flowcharts
  • Use precise notation (x > y NOT "x is greater than y")