OCR A Level Computer Science Cheat Sheets
=========================================
1) Data Structures Cheat Sheet
------------------------------
- Array:
- Fixed size, indexed collection of elements.
- Access by index is O(1).
- Insertion/deletion expensive if not at the end (O(n)).
- Stack:
- Last In First Out (LIFO).
- Operations: PUSH (add), POP (remove).
- Used in recursion, undo features.
- Queue:
- First In First Out (FIFO).
- Operations: ENQUEUE (add), DEQUEUE (remove).
- Used in scheduling, buffering.
- Linked List:
- Collection of nodes, each containing data + pointer to next node.
- Dynamic size, efficient insertions/deletions O(1) if position known.
- Access by index O(n).
- Tree:
- Hierarchical structure, nodes with children.
- Binary tree: max 2 children per node.
- Used in searching, sorting (e.g., binary search trees).
- Hash Table:
- Key-value pairs.
- Fast access O(1) average, uses hash functions.
- Collisions handled by chaining or open addressing.
- Graph:
- Nodes (vertices) connected by edges.
- Can be directed/undirected.
- Used for networks, pathfinding.
---
2) Python / Pseudocode Syntax Cheat Sheet
-----------------------------------------
- Variables and assignment:
x = 5
name = "Alice"
- Conditionals:
IF condition THEN
statements
ELSE
other statements
- Loops:
FOR i FROM 0 TO 10 DO
statements
WHILE condition DO
statements
=========================================
1) Data Structures Cheat Sheet
------------------------------
- Array:
- Fixed size, indexed collection of elements.
- Access by index is O(1).
- Insertion/deletion expensive if not at the end (O(n)).
- Stack:
- Last In First Out (LIFO).
- Operations: PUSH (add), POP (remove).
- Used in recursion, undo features.
- Queue:
- First In First Out (FIFO).
- Operations: ENQUEUE (add), DEQUEUE (remove).
- Used in scheduling, buffering.
- Linked List:
- Collection of nodes, each containing data + pointer to next node.
- Dynamic size, efficient insertions/deletions O(1) if position known.
- Access by index O(n).
- Tree:
- Hierarchical structure, nodes with children.
- Binary tree: max 2 children per node.
- Used in searching, sorting (e.g., binary search trees).
- Hash Table:
- Key-value pairs.
- Fast access O(1) average, uses hash functions.
- Collisions handled by chaining or open addressing.
- Graph:
- Nodes (vertices) connected by edges.
- Can be directed/undirected.
- Used for networks, pathfinding.
---
2) Python / Pseudocode Syntax Cheat Sheet
-----------------------------------------
- Variables and assignment:
x = 5
name = "Alice"
- Conditionals:
IF condition THEN
statements
ELSE
other statements
- Loops:
FOR i FROM 0 TO 10 DO
statements
WHILE condition DO
statements