What Is a Stable Sort? Concrete Examples and Interview Impact
What is a stable sort? Learn the definition, which algorithms are stable, and why stability matters for multi-key sorting and coding interviews.
Page 16 of 61 · Ideas for curious minds in tech.
Back to the archiveWhat is a stable sort? Learn the definition, which algorithms are stable, and why stability matters for multi-key sorting and coding interviews.

The quicksort partition step explained: Lomuto vs Hoare schemes, pivot selection, and how it powers Quickselect and the Dutch National Flag problem.

Quickselect finds the kth largest element in an array in O(n) average time. Learn the partition step, randomized pivot, and when to use it over a heap.

A monotonic queue solves the sliding window maximum in O(n). Learn the two eviction rules, why it beats a heap, and how to recognize the pattern.

A monotonic stack solves next greater element problems in O(n) by maintaining a sorted invariant. Learn what it is, how it works, and when interviews test it.

A difference array makes every range update O(1) by deferring work to one reconstruction pass. Learn when to use it and which LeetCode problems it solves.

Prefix sum algorithm explained: build once in O(n), query any range in O(1). Covers the hash map trick, 2D prefix sums, and 14 language implementations.

The prime sieve algorithm finds every prime up to N in O(n log log n). Learn why the inner loop starts at p², the complexity proof, and LeetCode 204 patterns.

GCD algorithm explained: Euclidean approach, O(log min(a,b)) complexity, LCM formula, and every coding interview pattern that depends on it.

Modular arithmetic appears in every counting DP. Learn why 10^9 + 7, how to avoid overflow, and the negative mod trap for your coding interview.

What is two's complement? Learn how computers represent negative integers in binary, why INT_MIN breaks Java, and the interview traps it causes.

A bitmask is an integer used as a compact set of flags. Learn the six operators, five core operations, and how bitmask DP solves subset problems in interviews.

A negative weight cycle makes shortest paths undefined. Learn why Dijkstra fails, how Bellman-Ford detects cycles, and the currency arbitrage trick.

The shortest path algorithm guide for coding interviews: BFS, Dijkstra, Bellman-Ford, and Floyd-Warshall with decision rules and Python code.

In-degree counts edges pointing in; out-degree counts edges going out. Learn how both power Kahn's algorithm, topological sort, and cycle detection.

A bipartite graph can be 2-colored so no adjacent vertices share a color. Learn detection, the odd cycle theorem, and the interview problems it solves.

A minimum spanning tree connects all graph vertices at minimum total edge weight. Learn Kruskal's, Prim's, and the interview patterns that signal MST.

A spanning tree uses all V vertices, V-1 edges, and no cycles. Learn what spanning trees are, how MST algorithms work, and where they show up in interviews.
Strongly connected components explained: definition, Kosaraju's and Tarjan's algorithms, the condensation DAG, and when SCCs come up in coding interviews.

A connected component is a maximal set of reachable nodes in a graph. Learn DFS, BFS, and Union-Find with Python code and interview patterns.

Learn what a directed acyclic graph (DAG) is, how cycle detection works, and how topological sort and DP connect to DAGs in coding interviews.

Path compression makes union find nearly O(1) per operation. Learn the one-line fix, three variants, and all 14 language implementations.

Union by rank keeps union-find trees short by always merging shorter under taller. Learn the O(log n) proof, the equal-rank case, and interview implementation.

Learn how the disjoint set data structure works, with path compression, union by size, and O(α(n)) implementations in 14 programming languages.