Data Structures Cheat Sheet 2026
The 30 highest-yield Data Structures facts, distilled from real exam questions. Print it, save it as a PDF, or study it here — free, no sign-up.
60 questions
90 min time limit
70.00% to pass
- Which data structure can be implemented using two linked lists to support O(1) push, pop, and min operations? → Min-stack
- Which sorting algorithm has the best worst-case time complexity? → Merge sort
- In a 2D array stored in row-major order, which access pattern is more cache-friendly? → Row-by-row access
- Which approach finds the kth largest element in an unsorted array in average O(n) time? → Quickselect algorithm
- Which algorithm uses a stack to evaluate postfix (Reverse Polish Notation) expressions? → Push numbers, pop two operands when an operator is found, push result
- Which of the following uses the first-in, first-out (FIFO) method? → Queue
- What is the time complexity of deleting a node from a singly linked list given only a pointer to that node (not the previous)? → O(1) by copying successor data
- Which problem can be solved optimally using a hash map to track complement pairs? → Two Sum: finding two indices that add to a target
- What is the space complexity of storing a string of length n? → O(n)
- What triggers rehashing in a hash table? → When the load factor exceeds a threshold (commonly 0.75)
- Two-dimensional arrays are also referred to as → both A & B
- Which tree traversal visits nodes in ascending order for a Binary Search Tree? → In-order
- Which of the following is NOT a valid graph traversal algorithm? → Inorder Traversal
- What is the time complexity of finding an element in a sorted rotated array using binary search? → O(log n)
- What is a collision in a hash table? → Two different keys hashing to the same bucket index
- Why is the worst-case time complexity of hash table lookup O(n)? → All keys hash to the same bucket, creating a single chain of length n
- Which string algorithm preprocesses a failure function to skip redundant comparisons? → KMP (Knuth-Morris-Pratt)
- When determining the efficiency of an algorithm, the time factor is → Counting the number of key operations
- Because aposterior analysis is more accurate than apriori analysis, it is → it assumes all other facets to be dynamic
- What is the time complexity of the push and pop operations on a stack? → O(1) for both
- What is the key property of a sorted rotated array that enables binary search on it? → At least one half of the array is always sorted
- What does it mean for a binary tree to be height-balanced? → The height difference between left and right subtrees is at most 1 for every node
- How can a queue be implemented using two stacks with amortized O(1) enqueue and dequeue? → Enqueue to stack1; dequeue pops from stack2, transferring from stack1 when stack2 is empty
- Which hash function property ensures similar inputs produce very different outputs? → Avalanche effect
- What is an LRU Cache and which data structures implement it in O(1) for both get and put? → LRU cache using a doubly linked list and hash map
- How can two sorted linked lists be merged in O(m+n) time? → Compare heads iteratively and link the smaller node
- What is the time complexity of inserting a node at the beginning of a singly linked list? → O(1)
- What is the time complexity of insertion into a binary min-heap (underlying a priority queue)? → O(log n)
- How does partitioning a linked list around a value x (like in quicksort) work? → Maintain two separate lists for = x nodes, then concatenate
- What is the Fenwick tree (Binary Indexed Tree) optimized for? → Prefix sum queries and point updates in O(log n) with less memory than a segment tree
Turn these facts into recall: