This page is due for review. Re-read the key points and answer the self-check questions before recording your video.
Algorithms · Hub
Linear structures
Eight ways to keep items in a line. Arrays give instant access by index; linked lists make relinking cheap; stacks, queues and deques restrict where you add and remove; a priority queue always serves the most urgent item.
Why it matters: the structure you pick decides which operations are $O(1)$ and which are $O(n)$. Choosing well is often a bigger speed-up than any clever algorithm.
5 random questions mixed from all eight structures.
Mixed review
Answer each one out loud before opening the sample answer.
flowchart TD
A{"Which item do you remove next?"} -->|"the newest"| S["Stack"]
A -->|"the oldest"| Q["Queue"]
A -->|"newest or oldest, both ends"| D["Deque"]
A -->|"the most urgent"| P["Priority queue"]
A -->|"any item"| B{"Need access by index?"}
B -->|yes| AR["Array"]
B -->|no| C{"Delete nodes you already hold, or walk backwards?"}
C -->|yes| DL["Doubly linked list"]
C -->|no| E{"Cycle through items forever?"}
E -->|yes| CL["Circular linked list"]
E -->|no| SL["Singly linked list"]
Key points
Arrays give $O(1)$ access because the address of item $i$ is computed directly.
Linked lists give $O(1)$ relinking because inserting next to a known node changes only pointers, not positions.
Stacks, queues and deques are $O(1)$ because they only ever touch the ends.
A priority queue costs $O(\log n)$ because a heap keeps only partial order, along one root-to-leaf path.
Pick by your most frequent operation because every structure makes some operations cheap by making others expensive.