Push, pop, enqueue and dequeue โ see how stacks, queues and other data structures work with animated operations.
Designed with the WJEC specification in mind
CS A-Level Unit 3CS GCSE ยง1.2
๐ฆ Stack
๐ถ Queue
๐ Linked List
๐ณ Binary Tree
๐๏ธ Hash Table
๐ฆ
Stack (LIFO โ Last In, First Out)
Size: 0 / 8
Ready. Push some values onto the stack.
Stack operations: Push (add to top), Pop (remove from top), Peek (look at top without removing). Real-world examples: Undo button, browser back button, function call stack, reversing a string. Time complexity: Push O(1), Pop O(1), Peek O(1)
๐ถ
Queue (FIFO โ First In, First Out)
Size: 0 / 8
Ready. Enqueue some values.
Queue operations: Enqueue (add to rear), Dequeue (remove from front), Peek (look at front). Real-world examples: Print queue, customer service queue, message buffers, CPU scheduling. Time complexity: Enqueue O(1), Dequeue O(1), Peek O(1)
๐
Linked List
Ready. Add some nodes.
Linked List: Each node stores a value AND a pointer to the next node. Unlike arrays, elements aren't stored contiguously in memory. Advantages: Dynamic size, efficient insertion/deletion at front O(1). Disadvantages: No random access (must traverse from head), extra memory for pointers.
๐ณ
Binary Search Tree (BST)
Insert values to build a Binary Search Tree.
Binary Search Tree (BST): Each node has at most two children. Left child is always smaller, right child is always larger. Traversals: In-order (LeftโRootโRight) gives sorted order. Pre-order (RootโLeftโRight) copies the tree. Post-order (LeftโRightโRoot) deletes safely. Search: O(log n) average โ halves the search space each step, like binary search on an array. CS A-Level Unit 3
๐๏ธ
Hash Table
Insert key-value pairs into the hash table.
Hash Table: Uses a hash function to convert a key into an array index. Allows O(1) average lookup time โ much faster than searching a list. Hash Function: Takes the key and produces a number (index). Simple example: sum of character codes mod table size. Collisions: When two keys hash to the same index. Resolved here using linear probing โ if the slot is taken, try the next one. Load Factor: Number of items รท table size. Higher load factor = more collisions = slower lookups. CS A-Level Unit 3