250 Data Structures & Algorithms Flashcards for Memly
In this subject, speed comes from knowing the tradeoff before you touch the code.
Add every card on the free plan. Importing runs no AI generation and spends no AI credits. You'll need a Memly account.
In data structures and algorithms, the miss is usually not forgetting a name. It is picking a hash table when ordering matters, trusting an average case when the worst case decides the answer, or blanking on the boundary rule that makes binary search go wrong. Interview and exam problems turn on those choices more than on raw memorization. This deck gives you 250 cards split across analysis (30), linear-structures (40), trees-and-heaps (45), sorting-and-searching (40), graphs (45), and algorithm-design (50). Each card covers one structure, algorithm, or concept, with the back cut into Meaning, Complexity, and Watch for. You review the idea, the bound, and the case that breaks the obvious answer together. Where average and worst case differ, the card says so. On a spaced-repetition schedule, the answers you really know stop showing up so often, while the weak spots keep coming back until the tradeoffs stick. That turns review from rereading notes into naming the right tool on demand. The deck leaves out long proofs and full implementations by choice, so practice stays centered on recognition, complexity, and failure cases.
What happens when you add it
- 1
The button opens Memly and the whole deck lands in your account.
- 2
Each card gets its own schedule, based on how well you actually recall it.
- 3
They are your cards afterwards — rewrite, delete or reorganize them freely.
What's inside
Showing 100 representative cards from the full 250-card deck.
| Front | Back |
|---|---|
| Big-O notation | Meaning: An asymptotic upper bound used to cap how fast running time or memory can grow for large inputs. Complexity: Expresses time O(f(n)) or space O(g(n)). It does not claim the bound is tight. Watch for: Often confused with Big-Theta. A function can be O(f(n)) and still be much smaller. |
| Worst-case analysis | Meaning: It measures the cost on the hardest input of size n to give a guaranteed performance bound. Complexity: If the slowest size n input costs f(n) time and g(n) space, the bounds are O(f(n)) and O(g(n)). Watch for: It may overstate typical performance. Do not treat it as average case. |
| Amortised analysis | Meaning: A technique that spreads rare expensive operations across a sequence to bound the average cost per operation. Complexity: If m operations cost O(m) total, the amortised time is O(1) each. Space is the structure's actual space. Watch for: No probability model is used. It is not the same as average-case analysis. |
| Potential method | Meaning: An amortised proof method that uses a potential function to track stored work in the data structure state. Complexity: Amortised cost is actual cost plus change in potential. It often proves O(1) amortised updates over a sequence. Watch for: The potential must stay nonnegative. A bad potential gives an invalid bound. |
| Divide-and-conquer recurrence | Meaning: A recurrence like T(n)=aT(n/b)+f(n) that models splitting a problem, solving parts, and combining results. Complexity: Time depends on a, b, and f(n). Stack space is usually O(log n) when each call shrinks by a constant factor. Watch for: Unbalanced splits or changing branch factors can break this simple form and the Master theorem. |
| Substitution method | Meaning: A proof technique that guesses a bound for a recurrence and verifies it by induction. Complexity: Used to prove time O(f(n)) or Θ(f(n)). Space still comes from the algorithm's recursion depth. Watch for: A weak inductive hypothesis often fails. Lower-order terms may need extra slack in the guess. |
| Equal-work recurrence case | Meaning: The Master theorem case where f(n) matches n^log_b a up to a log factor, so each level contributes similar work. Complexity: If f(n)=Θ(n^log_b a log^k n), then T(n)=Θ(n^log_b a log^(k+1) n) for k≥0. Stack space is O(log n). Watch for: This standard form assumes k≥0. Do not use it for polynomially larger or smaller f(n). |
| Dynamic array append | Meaning: Adding an item to the end of a resizable array is a classic example of amortised analysis. Complexity: Time is O(1) amortised and O(n) on a resize. Space is O(n) because extra capacity is kept. Watch for: A single append can be slow during growth. It is not O(1) in the worst case. |
| Space complexity | Meaning: It measures how memory usage grows with input size, including data, recursion, and temporary storage. Complexity: Reported as total space O(f(n)). Time is analyzed separately and may have a different growth rate. Watch for: Do not mix total space with auxiliary space. Some conventions count the input and some do not. |
| Call stack space | Meaning: Memory used by active function calls, which matters when recursion creates one frame per level. Complexity: If recursion depth is d, stack space is usually O(d). Time may be much smaller or larger than d. Watch for: Hidden stack use is easy to miss. An iterative version can cut this space. |
| Telescoping recurrence | Meaning: A recurrence solved by expanding terms until most parts cancel, used to turn recursive cost into an explicit sum. Complexity: For T(n)=T(n-1)+f(n), time is often O(the sum of f(i) for i from 1 to n). Space is O(n) with direct recursion or O(1) if rewritten iteratively. Watch for: It is not the right tool for branching recurrences like T(n)=2T(n/2)+n, which do not collapse into one chain. |
| Input space | Meaning: The memory needed to represent the given input, used to separate total space from extra working memory. Complexity: If n measures the whole input length, input space is O(n). Total space is O(input space + auxiliary space). Watch for: It is often confused with auxiliary space. In-place limits extra space, not the bytes already occupied by the input. |
| Array | Meaning: A fixed-size contiguous sequence used when you need O(1) indexing and compact storage. Complexity: Index and update are O(1). Search is O(n). Insert or delete away from the end is O(n). Space is O(n). Watch for: Middle edits shift many elements. O(1) access does not mean O(1) search. |
| Resizing by doubling | Meaning: A growth policy that multiplies capacity by a constant factor so dynamic-array append stays fast over time. Complexity: One resize costs O(n) time and O(n) extra space while copying. Across many appends, average append stays O(1). Watch for: Growing by one slot each time makes total appends O(n^2). Very large factors waste memory. |
| Array deletion | Meaning: Removing an element from an array while keeping remaining elements contiguous and in order. Complexity: If the index is known, shifting makes average and worst time O(n). Extra space is O(1) in place. Watch for: Deleting near the front shifts many items. Lazy tombstones save time but hurt scans and memory use. |
| Singly linked list | Meaning: A chain of nodes with one next pointer, used for cheap inserts or deletes near the head or after a known node. Complexity: Head insert or delete is O(1). Search and indexed access are O(n). Space is O(n). Watch for: You cannot move backward in O(1). Random access is much worse than in an array. |
| Sentinel node | Meaning: A dummy node at a boundary that removes null edge cases, used to simplify linked-list code. Complexity: Traversal stays O(n). Insert or delete near known nodes stays O(1). It adds O(1) extra space. Watch for: The sentinel holds no user data. Loops must stop at it rather than process it. |
| Stack | Meaning: A last-in first-out collection used for undo, parsing, and depth-first processing. Complexity: Push, pop, and top are O(1). Search is O(n). Space is O(n). Watch for: It is the wrong model when the oldest item must leave first. Deep recursion can overflow the call stack. |
| Deque | Meaning: A double-ended queue that supports insertion and removal at both ends, used for sliding windows and task buffers. Complexity: Push or pop at either end is O(1). Search is O(n). Space is O(n). Watch for: Fast ends do not make middle access fast. It is often confused with a stack or an ordinary queue. |
| Hash table | Meaning: A key-value structure that uses hashed indices for fast lookup, insert, and delete. Complexity: Lookup, insert, and delete are avg O(1) and worst O(n). Space is O(n). Watch for: Heavy collisions or bad resizing can collapse performance. Iteration order is not sorted and may not be stable. |
| Load factor | Meaning: The ratio n/m of stored entries to table slots, used to predict collisions and trigger resizing. Complexity: Computing or updating it is O(1). Low n/m supports avg O(1) table ops, while worst case is O(n). Space for the table is O(m). Watch for: High occupancy increases probes, especially in open addressing. Different collision schemes tolerate different ranges. |
| Open addressing | Meaning: A collision strategy that keeps all entries in the table and probes for another slot when a collision happens. Complexity: Lookup, insert, and delete are avg O(1) at low load and worst O(n). Space is O(m). Watch for: Deletion needs tombstones or careful back-shifting. Performance drops sharply as occupancy grows. |
| Quadratic probing | Meaning: An open-addressing method that uses quadratic step sizes to spread probes and reduce primary clustering. Complexity: Lookup, insert, and delete are avg O(1) at low load and worst O(n). Space is O(m). Watch for: It still has secondary clustering. Bad table sizes or step rules can fail to visit every slot. |
| Prefix sum array | Meaning: Stores cumulative totals so a range sum can be answered from two lookups, useful for many static interval queries. Complexity: Build O(n) time and O(n) space. Range sum query O(1). Single update O(n) if prefixes stay explicit. Watch for: Best for mostly read-only data. It is often confused with a difference array, which optimizes range updates instead. |
| Gap buffer | Meaning: Keeps an array with an empty gap near the cursor so nearby text edits are fast in text editors. Complexity: Insert or delete at the gap O(1) amortized. Moving the gap O(n). Space O(n). Watch for: Long cursor jumps are costly. It is easy to confuse with a linked list, but locality is usually much better. |
| Floyd's cycle detection | Meaning: Uses slow and fast pointers to detect a cycle in a linked structure without extra memory. Complexity: Time O(n). Extra space O(1). Watch for: It detects a cycle and can locate its entry, but it is not the same as reversing a list or marking visited nodes. |
| Min stack | Meaning: A stack that can return the current minimum element along with normal push and pop operations. Complexity: Push, pop, top, and min are O(1). Extra space is O(n). Watch for: Equal minima need correct handling. It is not a priority queue, since removal order stays last in first out. |
| Rehashing | Meaning: Rebuilds a hash table at a new size and reinserts keys to restore low collision cost as occupancy changes. Complexity: A resize step is O(n) time. Insert is O(1) average amortized and O(n) worst. Space O(n). Watch for: Cached bucket indexes become invalid after resize. A full rebuild can cause latency spikes. |
| Cuckoo hashing | Meaning: Places each key in one of a small number of candidate buckets and evicts existing keys on conflict. Complexity: Lookup O(1) worst. Insert O(1) average and O(n) worst when evictions cycle and force rehash. Space O(n). Watch for: Insertion cycles and high load can trigger rehash. It is not the same as double hashing, which uses one probe sequence. |
| Complete binary tree | Meaning: A binary tree whose last level is filled left to right after all higher levels, which makes it efficient to store in an array. Complexity: With n nodes, height is O(log n), traversal is O(n), and storage is O(n). Parent and child index jumps are O(1) in an array layout. Watch for: Do not confuse complete with full or perfect. Missing nodes may appear only at the far right of the last level. |
| Postorder traversal | Meaning: Visits left subtree, then right subtree, then root, and is useful for deleting a tree or evaluating expression trees bottom up. Complexity: Traversing n nodes takes O(n) time and O(h) extra space for recursion or a stack. Watch for: The root is processed last. It is easy to swap it with preorder by mistake. |
| Binary search tree | Meaning: An ordered binary tree with smaller keys on the left and larger keys on the right, used for dynamic ordered sets and maps. Complexity: Average search, insert and delete are O(log n). Worst case is O(n) in a skewed tree. Space is O(n). Watch for: Choose a duplicates policy. Without balancing, sorted input can degrade it to linear height. |
| Order-statistics tree | Meaning: A balanced BST with subtree sizes, used to find ranks and the kth smallest key while supporting updates. Complexity: Search, insert, delete, rank and select are O(log n) worst case when the underlying BST stays balanced. Space is O(n). Watch for: Every update and rotation must also fix stored subtree sizes. Duplicates need a clear counting rule. |
| Red-black tree | Meaning: A self-balancing BST that uses coloring rules to bound height, often used for ordered maps and sets. Complexity: Search, insert and delete are O(log n) worst case. Space is O(n). Watch for: You must maintain no red-red parent-child link and equal black height on all root-to-leaf paths. |
| Binary heap | Meaning: A complete binary tree with heap order, usually stored in an array, used to implement a fast priority queue. Complexity: Peek root is O(1). Insert and extract root are O(log n). Building from n items is O(n). Space is O(n). Watch for: Only the root is globally smallest or largest. Searching for an arbitrary key is O(n), not O(log n). |
| Heapsort | Meaning: A comparison sort that builds a heap and repeatedly removes the root to produce a sorted array in place. Complexity: Average and worst time are O(n log n). Extra space is O(1) with an array heap. Watch for: It is not stable and often has worse cache behavior than quicksort. It does guarantee worst-case O(n log n). |
| Trie | Meaning: A tree over characters where each root-to-node path is a prefix, used for dictionaries, autocomplete and prefix tests. Complexity: Search, insert and delete are O(m) for key length m. Space is O(number of nodes), which can be much larger than storing the keys alone. Watch for: Memory use depends heavily on alphabet size and sparsity. It does not keep keys in BST order. |
| Segment tree | Meaning: A balanced binary tree over array intervals, used for range queries and point updates with an associative merge rule. Complexity: Build is O(n). Range query and point update are O(log n). Space is O(n), often around 4n in array form. Watch for: The merge function and identity element must fit the query. It is heavier than a Fenwick tree for simple sums. |
| Threaded binary tree | Meaning: A binary tree that replaces null child links with inorder predecessor or successor links so traversal needs no stack. Complexity: Traversal is O(n) time and O(1) extra space. Search, insert, and delete are O(h) time and must maintain threads. Watch for: Updates are easy to get wrong. Do not confuse thread links with parent pointers. |
| Euler tour technique | Meaning: A DFS linearization that records visit order so subtree and ancestor tasks can be turned into array interval problems. Complexity: Building the tour is O(n) time and space. Subtree interval lookup is O(1). Extra query cost depends on the index used. Watch for: Conventions differ on when nodes are recorded. Do not mix subtree entry times with the tour used for lowest common ancestor queries. |
| B-tree | Meaning: A multiway balanced search tree for external storage that keeps many keys per node to reduce page reads. Complexity: Search, insert, and delete are O(log n) worst case. Space is O(n). Watch for: Pick node size to match disk pages. Do not confuse it with a B+ tree, where records are kept in leaves. |
| 2-3 tree | Meaning: A balanced search tree whose nodes hold one or two keys, keeping all leaves at the same depth. Complexity: Search, insert, and delete are O(log n) worst case. Space is O(n). Watch for: Updates can cascade splits or merges upward. Do not confuse it with a 2-3-4 tree. |
| Binomial heap | Meaning: A meldable heap built from binomial trees, useful when unioning priority queues efficiently matters. Complexity: Insert, meld, extract-min, decrease-key, and delete are O(log n) worst case. Find-min is O(log n) or O(1) with a min pointer. Space O(n). Watch for: It often has higher constants than a binary heap. The structure is a forest rather than one complete tree. |
| Skew heap | Meaning: A self-adjusting meldable heap that swaps children during merges instead of storing balance data. Complexity: Find-min is O(1). Meld, insert, and delete-min are O(log n) amortized. Space O(n). Watch for: There is no strict height bound. A single unlucky merge can take O(n) time. |
| Aho-Corasick automaton | Meaning: A trie with failure links for finding many exact patterns at once while scanning the text one pass. Complexity: Build is O(total pattern length) time and space. Search is O(text length plus matches). Watch for: It is for exact multi-pattern search, not approximate matching. Large alphabets raise constants. |
| Interval tree | Meaning: An augmented balanced BST over intervals that reports all intervals overlapping a query point or interval. Complexity: Insert and delete are O(log n). Overlap search is O(log n + k), where k is reported intervals. Space O(n). Watch for: The max-end augmentation is essential. Do not confuse it with a segment tree, which indexes coordinates. |
| Stability | Meaning: A stable sort keeps equal-key items in their original relative order, which matters when records are sorted by multiple keys. Complexity: Property only. Naming it is O(1). Stable algorithms span O(n) to O(n log n) or O(n^2) time and may use O(1) or O(n) extra space. Watch for: It applies to equal keys only. It is often confused with deterministic output or with preserving all input order. |
| Insertion sort | Meaning: Insertion sort grows a sorted prefix by inserting each new item into its place, so it works well on small or nearly sorted arrays. Complexity: Best O(n). Average and worst O(n^2). Extra space O(1). Watch for: Reverse-sorted input triggers the quadratic case. It is often confused with selection sort. |
| Quicksort | Meaning: Quicksort partitions around a pivot and recursively sorts the sides, making it fast in practice on many arrays. Complexity: Average O(n log n). Worst O(n^2). Extra space O(log n) average and O(n) worst from recursion. Watch for: Bad pivots or many duplicates can hurt badly without three-way partitioning. It is often confused with quickselect. |
| Counting sort | Meaning: Counting sort counts occurrences of integer keys in a bounded range and reconstructs the sorted output without comparisons. Complexity: Time O(n + k). Extra space O(n + k) for stable output, or O(k) if only counts are needed. Watch for: A huge or sparse key range makes it impractical. Negative keys need offset handling. |
| Binary search | Meaning: Binary search repeatedly halves a sorted search space to find a target or determine that it is absent. Complexity: Best O(1). Average and worst O(log n). Extra space O(1) iterative or O(log n) recursive. Watch for: It needs monotone sorted data. Duplicates and off-by-one boundary rules cause many bugs. |
| Upper bound | Meaning: Upper bound finds the first position whose value is greater than a target, often to get the end of an equal-value range. Complexity: Time O(log n). Extra space O(1). Watch for: It returns the insertion point after duplicates. It is often confused with lower bound. |
| Interpolation search | Meaning: Interpolation search estimates the probe position from key values, so it can beat binary search on uniformly distributed numbers. Complexity: Average O(log log n) on uniform data. Worst O(n). Extra space O(1). Watch for: Skewed or clustered values destroy its advantage. It is not robust like binary search. |
| Parametric search | Meaning: Parametric search turns an optimization problem into binary search over answers by testing a monotone feasibility condition. Complexity: Time O(log R) feasibility checks, or O(f(n) log R) if one check costs O(f(n)). Extra space is usually O(1). Watch for: The feasible set must be monotone. It is often confused with ternary search on unimodal functions. |
| Quickselect | Meaning: Quickselect partitions like quicksort but recurses into one side, making it useful for finding the kth smallest item. Complexity: Average O(n). Worst O(n^2). Extra space O(log n) average and O(n) worst from recursion. Watch for: Bad pivots and many duplicates can hurt. It is often confused with fully sorting the array. |
| Top-k heap | Meaning: Top-k heap keeps only the best k items seen so far, which is useful for streaming or very large inputs. Complexity: Time O(n log k). Extra space O(k). Watch for: The retained k items are not automatically sorted. Use the heap direction that matches smallest or largest. |
| Bubble sort | Meaning: A comparison sort that repeatedly swaps adjacent out-of-order items and is used mainly for teaching or tiny nearly sorted inputs. Complexity: Average and worst time O(n^2). Best time O(n) with early exit, otherwise O(n^2). Space O(1). Watch for: Without a swapped flag, sorted input does not improve. It is often confused with insertion sort. |
| Introsort | Meaning: A hybrid comparison sort that starts with quicksort and switches strategies to keep performance predictable in libraries. Complexity: Average and worst time O(n log n). Space O(log n) from recursion. Watch for: It is often mistaken for plain quicksort. The depth limit is what prevents O(n^2) worst case. |
| Jump search | Meaning: A search algorithm for sorted arrays that jumps ahead by blocks and then scans linearly within the right block. Complexity: Average and worst time O(√n). Space O(1). Watch for: It needs a sorted array and random access. It is slower than binary search asymptotically. |
| Ternary search | Meaning: A search algorithm that probes two interior points to find an extremum in a unimodal sequence or function. Complexity: Discrete case O(log n). Continuous case O(log((r-l)/ε)) to precision ε. Space O(1). Watch for: It needs a unimodal target. On sorted data it offers no advantage over binary search. |
| Floyd-Rivest algorithm | Meaning: A randomized selection algorithm that uses sampling to find the kth smallest element faster in practice than plain quickselect. Complexity: Expected time O(n). Worst time O(n^2). Space O(log n) with recursion. Watch for: It has no worst-case linear guarantee. It is often confused with median of medians. |
| Tournament method for second largest | Meaning: A selection method that finds the maximum and then the largest element that lost directly to it. Complexity: Time O(n). Extra space O(log n) if the tournament is kept balanced. Watch for: It only helps for the second largest element. You must remember the losers compared with the maximum. |
| Patience sorting | Meaning: A comparison sort that deals items into ordered piles and then merges pile tops, and the same pile idea is also used to reason about longest increasing subsequences. Complexity: Time O(n log n) average and worst. Space O(n). Watch for: The pile-building step alone is not the full sort. Often confused with the LIS routine that never outputs all items in order. |
| Fractional cascading | Meaning: A search technique that links related sorted lists so one binary search can be reused to search many lists quickly. Complexity: Preprocessing O(N) time and space for total size N. Query O(log N + k) across k linked lists. Watch for: It pays off on repeated searches over related lists. It gives little benefit on unrelated arrays or one-off queries. |
| Adjacency list | Meaning: Stores, for each vertex, the list of outgoing neighbors and is used for sparse graphs and fast neighbor traversal. Complexity: Build O(V+E). Edge lookup O(deg(u)) worst. Neighbor iteration O(deg(u)). Space O(V+E). Watch for: Dense graphs make it less cache friendly than a matrix. It is often confused with an edge list. |
| Edge list | Meaning: Stores each edge as a pair or weighted tuple and is used when algorithms mainly scan or sort all edges. Complexity: Build O(E). Edge lookup O(E) worst. Full scan O(E). Space O(E). Watch for: Poor for finding one vertex's neighbors. It is not an adjacency list. |
| Breadth-first search | Meaning: Explores vertices by increasing distance from a start node and is used for reachability and shortest paths in unweighted graphs. Complexity: O(V+E) time with adjacency lists, O(V^2) with a matrix. Space O(V). Watch for: Weighted edges break shortest-path correctness. Mark vertices visited when enqueuing. |
| Topological sort | Meaning: Produces a linear order of a DAG so every directed edge goes from earlier to later and is used for dependency scheduling. Complexity: O(V+E) time and O(V) space. Watch for: Any directed cycle makes it impossible. Multiple valid orders can exist. |
| Dijkstra's algorithm | Meaning: Finds single-source shortest paths in a graph with nonnegative edge weights and is used for routing and least-cost paths. Complexity: With adjacency lists and a binary heap, O((V+E) log V) time and O(V) extra space. Watch for: A negative edge can give wrong answers. It is often confused with Prim because both use a priority queue. |
| Floyd-Warshall algorithm | Meaning: Computes all-pairs shortest paths by dynamic programming over intermediate vertices and is used on small dense weighted graphs. Complexity: O(V^3) time and O(V^2) space. Watch for: Negative cycles invalidate distances. Path reconstruction needs a separate next-step table. |
| Shortest path tree | Meaning: Stores one predecessor edge per reachable vertex so paths from a source have minimum total weight or hop count. Complexity: Built by BFS in O(V+E), by Dijkstra in O((V+E) log V), or by Bellman-Ford in O(VE). Space O(V). Watch for: It is not the same as a minimum spanning tree. Multiple shortest-path trees can exist. |
| Kruskal's algorithm | Meaning: Sorts edges by weight and adds them when they do not form a cycle, building an MST from lightest edges upward. Complexity: O(E log E) time and O(V+E) space. Watch for: On disconnected graphs it returns a minimum spanning forest. Equal weights can lead to many valid MSTs. |
| Strongly connected component | Meaning: A maximal set of vertices in a directed graph where every vertex can reach every other and is used to compress cycles. Complexity: All SCCs can be found in O(V+E) time and O(V) space. Watch for: This is for directed graphs. It is not the same as an undirected connected component. |
| Residual graph | Meaning: Shows remaining usable capacity and cancelable flow on each edge and is used by augmenting-path max-flow algorithms. Complexity: Stored in O(V+E) space. Updating one augmenting path is O(V) once the path is known. Watch for: You need reverse edges even if the original network had none. Residual capacity is not original capacity. |
| Edmonds-Karp algorithm | Meaning: A Ford-Fulkerson variant that always uses the shortest augmenting path in edge count, found by BFS. Complexity: O(VE^2) time and O(V+E) space. Watch for: It chooses shortest paths by edge count, not by capacity or cost. Dense graphs make it very slow. |
| Directed acyclic graph | Meaning: A directed graph with no directed cycles. It models dependencies and supports linear-time ordering and dynamic programs. Complexity: Storage is O(V+E) with lists or O(V^2) with a matrix. Testing acyclicity or ordering takes O(V+E) time and O(V) extra space. Watch for: Any directed cycle breaks it. Do not confuse a DAG with a tree, which is connected and acyclic in a different sense. |
| Bipartite graph | Meaning: A graph whose vertices can be split into two sets with every edge crossing sets. It models two-sided relationships and matching problems. Complexity: Testing by two-coloring with BFS or DFS takes O(V+E) time and O(V) space. Watch for: An odd cycle makes an undirected graph non-bipartite. Do not confuse it with complete bipartite graphs. |
| Bidirectional search | Meaning: A search that expands from source and target at the same time. It can cut the search depth for unweighted shortest paths. Complexity: With branching factor b and distance d, balanced cases use O(b^(d/2)) time and space. Worst case remains O(b^d). Watch for: It needs a known target and a way to search backward or generate reverse neighbors. |
| DFS tree | Meaning: The forest made of tree edges chosen by depth-first search. It exposes parent links, reachability, and edge classification. Complexity: Building it by running DFS takes O(V+E) time and O(V) extra space. Watch for: In a disconnected graph it is a forest, not one tree. It contains only discovery edges, not every reachable edge. |
| 0-1 BFS | Meaning: A shortest-path algorithm for graphs whose edge weights are only 0 or 1. It uses a deque instead of a priority queue. Complexity: Time is O(V+E). Space is O(V). Watch for: Any edge weight outside {0,1} breaks its guarantee. Do not replace general weighted shortest paths with it. |
| Shortest path in a DAG | Meaning: A single-source shortest-path method for DAGs that relaxes edges in topological order. It works even with negative edge weights. Complexity: Time is O(V+E). Space is O(V). Watch for: It requires the graph to be acyclic. A negative cycle cannot occur in a DAG. |
| Bridge | Meaning: An edge whose removal increases the number of connected components of an undirected graph. It marks a single point of failure. Complexity: All bridges can be found by one DFS with low-link values in O(V+E) time and O(V) extra space. Watch for: In multigraphs parallel edges can prevent an edge from being a bridge even if it looks critical. |
| Push-relabel algorithm | Meaning: A maximum-flow algorithm that pushes excess flow locally and relabels heights to restore progress. It works well on dense networks. Complexity: Generic worst-case time is O(V^2 E). Space is O(V+E). Watch for: It maintains a preflow, not a valid flow at every step. Do not confuse vertex heights with shortest-path distances. |
| Closest pair of points | Meaning: A divide-and-conquer algorithm for the nearest pair in the plane. It is used to beat the quadratic all-pairs check. Complexity: Time O(n log n). Space O(n). Watch for: The strip combine step must examine only nearby points. Confused with the O(n^2) brute-force method. |
| Activity selection algorithm | Meaning: A greedy scheduler that repeatedly picks the compatible activity with earliest finish time. It is used to maximize the number of non-overlapping activities. Complexity: Time O(n log n) with sorting, or O(n) after finish-time sorting. Space O(1) extra after sorting. Watch for: It maximizes count, not total weight. Confused with weighted interval scheduling, which needs dynamic programming. |
| Memoization | Meaning: A top-down dynamic programming technique that caches solved subproblems. It is used when recursive subproblems overlap. Complexity: Time O(S + T) if S states are each solved once and total transitions are T. Space O(S) plus recursion stack. Watch for: It helps only with overlapping subproblems. Confused with generic caching that lacks a clear state definition. |
| Longest common subsequence | Meaning: A dynamic programming problem that finds the longest sequence appearing in order in two strings. It is used for diffing and sequence comparison. Complexity: Time O(mn). Space O(mn), or O(min(m, n)) for length only. Watch for: A subsequence need not be contiguous. Confused with longest common substring. |
| Backtracking | Meaning: A depth-first search technique that builds a candidate step by step and abandons partial solutions that violate constraints. It is used for exact combinatorial search. Complexity: Worst-case time is often exponential, commonly O(b^d). Space O(d) for recursion depth. Watch for: Weak pruning causes blowups. Confused with dynamic programming, which reuses overlapping subproblems. |
| Subset sum problem | Meaning: A decision problem of whether some subset adds exactly to a target. It is a classic search problem and also admits dynamic programming. Complexity: Backtracking is O(2^n) time and O(n) space. DP is O(nW) time and O(W) or O(nW) space for target W. Watch for: The DP is pseudo-polynomial in the target value. Confused with partition, which asks for equal-sum halves. |
| PTAS | Meaning: A scheme that, for any fixed epsilon > 0, returns a solution arbitrarily close to optimal in polynomial time. It is used to trade accuracy for speed. Complexity: For fixed epsilon, time is polynomial in n, often O(n^(f(1/epsilon))). Space is polynomial. Watch for: Confused with FPTAS, which is also polynomial in 1/epsilon. A PTAS may still be impractical for small epsilon. |
| Miller-Rabin primality test | Meaning: A randomized test that checks whether a large integer is composite or probably prime. It is used in practical cryptographic key generation. Complexity: Time O(k log^3 n) bit operations for k rounds. Space O(log n). Watch for: Probably prime is not a proof for arbitrary n. Confused with Fermat's test, which fails on Carmichael numbers. |
| Fractional knapsack | Meaning: A greedy optimization problem where items can be split, so taking highest value density first gives the maximum value. Complexity: Time O(n log n) for sorting by value density. Extra space is O(1) beyond the sort or O(n) with copied data. Watch for: The greedy choice fails for the 0-1 version where items are indivisible. It is confused with 0-1 knapsack. |
| Minimum coin change | Meaning: A dynamic programming problem that finds the fewest coins needed to make a target amount from given denominations. Complexity: Time O(nA) for n coin types and amount A. Space O(A). Watch for: A greedy choice can fail on noncanonical coin systems. It is confused with counting-change, which asks for the number of ways. |
| Branch and bound | Meaning: A search technique that explores a state tree but prunes branches whose bound proves they cannot beat the best known solution. Complexity: Worst-case time is exponential. Space is O(depth) with DFS or exponential with best-first storage. Watch for: Weak bounds give little pruning. It is confused with backtracking, which prunes by infeasibility rather than by objective bounds. |
| Greedy set cover algorithm | Meaning: An approximation algorithm that repeatedly picks the set covering the most still-uncovered elements. Complexity: Time O(mn) for m sets and n elements with a simple implementation. Space O(m+n). Watch for: It is not exact and can be a logarithmic factor from optimal. It is confused with the exact set cover problem. |
| Median of medians algorithm | Meaning: A deterministic selection algorithm that chooses a robust pivot to find the kth smallest element with guaranteed linear time. Complexity: Worst-case O(n) time. Space O(log n) recursively or O(1) in an iterative implementation. Watch for: Higher constants make it slower in practice than quickselect on many inputs. |
| Gale-Shapley algorithm | Meaning: A deferred-acceptance algorithm that finds a stable matching between two sets such as students and schools. Complexity: O(n^2) time. O(n) extra space plus O(n^2) to store the preference lists. Watch for: Stable is not the same as maximum-weight matching. The result depends on which side proposes. |
| Pseudopolynomial time | Meaning: A running-time class where the bound is polynomial in a numeric value in the input, not in the input length. Complexity: Typical forms are O(nW) time and O(W) or O(nW) space, where W is a numeric bound. Watch for: It is not truly polynomial when W can be exponential in the number of input bits. |
| Reservoir sampling | Meaning: A randomized algorithm that keeps a uniform sample of k items from a stream of unknown length in one pass. Complexity: O(n) time and O(k) space. Watch for: Wrong replacement probabilities introduce bias. It is not the same as shuffling when all items fit in memory. |
| Held-Karp algorithm | Meaning: An exact dynamic programming algorithm for TSP that tracks the cheapest way to reach each city from each visited subset, used to find an optimal tour on small graphs. Complexity: O(n^2 2^n) time and O(n 2^n) space. Watch for: Exponential state growth makes it impractical for large n. It is often confused with Christofides, which is faster but only approximate. |
Frequently asked
How is the deck split across topics?
It has analysis (30), linear-structures (40), trees-and-heaps (45), sorting-and-searching (40), graphs (45), and algorithm-design (50). The mix keeps complexity, core structures, and named algorithms in the same review cycle.
What kinds of cards are in this deck?
You get single-topic cards such as Big-O notation, Binary search, and the Held-Karp algorithm. Each back is organized as Meaning, Complexity, and Watch for so the definition, the bound, and the failure case stay linked.
What does this deck leave out on purpose?
It does not try to be a full textbook or a code notebook. Long proofs, full implementations, and extended worked problems are left out so review stays focused on choosing the right structure or algorithm, recalling complexity, and spotting the case that breaks it.
Can I import the whole deck on the free plan?
Yes. Importing a saved deck runs no new AI generation and spends no AI credits, so the free plan imports all 250 cards. You can study, edit and delete them afterwards.
Will importing it twice create duplicates?
No. Cards you already have are skipped and only cards added in a revision come through. Including re-imports after deleting it, one official deck can be imported three times per account.
Can I use it on the web and in the mobile app?
Yes. The deck is added to your account rather than to a device, so the same cards and the same progress are there on the web, on iOS and on Android.
Can I edit the cards after importing?
Yes. Imported cards are yours: you can edit both sides, delete cards you do not need, change tags, and move cards to another deck.
250 Data Structures & Algorithms Flashcards for Memly
Add every card on the free plan. Importing runs no AI generation and spends no AI credits. You'll need a Memly account.
Related tools
No official exam questions are reproduced. Every card was written for this deck.Editorial reference date 2026-08-30.