Red-Black Trees Explained: Rules, Rotations & Real-World Usage
Understand Red-Black trees — the 5 rules, insertion cases, color flips, rotations, comparison with AVL, and why Java TreeMap and Linux use them.
277 posts · page 4 of 6
Understand Red-Black trees — the 5 rules, insertion cases, color flips, rotations, comparison with AVL, and why Java TreeMap and Linux use them.
Compare all four shortest path algorithms with Python code, complexity analysis, and a decision flowchart for choosing the right one.
Master fixed-size and variable-size sliding window techniques. Covers minimum window substring, longest substring with K distinct chars, and string permutation problems.
Master stack-based parsing patterns — balanced parentheses, minimum removals, longest valid parentheses, decode string, and basic calculator with Python solutions.
Learn sqrt decomposition for O(sqrt(n)) range queries and updates, plus Mo's algorithm for answering offline queries efficiently. Full Python implementations included.
Master sparse tables for O(1) range minimum/maximum queries with O(n log n) preprocessing. Learn construction, idempotent functions, and when to use sparse tables over segment trees.
Build a calculator from scratch — learn infix, prefix, and postfix notation, the Shunting Yard algorithm, postfix evaluation, and Python implementation.
Master the monotonic stack pattern — solve Next Greater Element, Next Smaller, stock span, and circular array variants with Python templates and visual walkthroughs.
Master SCCs with Kosaraju's two-pass DFS and Tarjan's low-link algorithm, including condensation graphs and real applications in Python.
Master subarray sum techniques — prefix sum for range queries, Kadane's algorithm for maximum subarray, hash map for subarray sum equals K, sliding window, and maximum product subarray.
Learn suffix arrays from scratch -- naive and O(n log^2 n) construction, LCP arrays, pattern searching with binary search, and applications like longest repeated substring.
Master topological sorting with Kahn's BFS and DFS approaches. Solve course scheduling, build dependencies, alien dictionary, and longest path in DAG problems.
Build binary trees from inorder + preorder, inorder + postorder, and preorder + postorder. Hashmap optimization, edge cases, and Python recursive solutions.
Find the diameter of a binary tree using DFS, solve maximum path sum, and understand the two-BFS approach for general trees. Full Python implementations.
Serialize binary trees to strings and deserialize them back. BFS and DFS approaches with null handling, Python implementations, and real-world uses.
Master opposite-direction, same-direction, and fast-slow two pointer patterns. Includes templates, container with most water, cycle detection, and sort colors.
Master the Z-algorithm for pattern matching in O(n) time. Learn Z-array construction, the Z-box optimization, and applications like finding string periods and distinct substrings.
Master advanced dynamic programming patterns — interval DP, tree DP with rerooting, bitmask DP, digit DP, and optimization techniques like Knuth's and divide-and-conquer optimization.
A comprehensive comparison of data structures — arrays vs linked lists, hash maps vs trees vs tries, heaps vs BSTs, stacks vs queues, sets vs Bloom filters, with decision flowcharts and complexity tables.
The 15 most common competitive programming patterns — prefix sums, difference arrays, coordinate compression, meet in the middle, sqrt decomposition, sparse tables, binary lifting, and Mo's algorithm.
How real-world systems use data structures and algorithms — B-trees in databases, skip lists in Redis, inverted indexes in search, Dijkstra in routing, DAGs in Git, consistent hashing, and Bloom filters.
Deep dive into advanced graph algorithms — Tarjan's and Kosaraju's for SCCs, bridges and articulation points, Euler paths, network flow, and 2-SAT with real-world applications.
A complete framework for solving coding interview problems — the 5-step method, pattern recognition, handling stuck moments, communication strategies, common mistakes, and a 100-problem practice roadmap.
Master advanced string algorithms — Z-algorithm, Rabin-Karp rolling hash, suffix arrays, Aho-Corasick multi-pattern matching, Manacher's palindrome algorithm, and string hashing techniques.
Deep dive into advanced tree algorithms — heavy-light decomposition, Euler tour technique, centroid decomposition, LCA with binary lifting, tree DP with rerooting, and virtual trees.
Learn to binary search on the answer space — the powerful technique behind problems like splitting arrays, Koko eating bananas, and capacity to ship packages.
Master the Floyd-Warshall algorithm — understand the DP recurrence, implement it in Python, detect negative cycles, and know when to pick it over Dijkstra.
Learn graph coloring fundamentals — check if a graph is bipartite using BFS/DFS, solve m-coloring with backtracking, and tackle classic interview problems.
Master the Knuth-Morris-Pratt algorithm — build the failure function, avoid redundant comparisons, and solve pattern matching problems in O(n + m) time.
Learn the monotonic stack technique — next greater element, stock span, largest rectangle, and trapping rain water solved with clean Python templates.
Master segment trees for range queries and updates. Covers build, query, update, lazy propagation, and applications for range sum, min, and max problems.
Complete guide to the Trie data structure. Covers insertion, search, prefix matching, deletion, and real-world applications like autocomplete and word puzzles.
A printable cheatsheet of time and space complexities for arrays, hashmaps, trees, heaps, graphs, sorts, and common algorithms. Includes worst-case notes and quick rules of thumb.
Solve Find Minimum in Rotated Sorted Array in logarithmic time with a modified binary search. Learn the pivot-finding invariant, edge cases, and how to extend the pattern to related problems.
Solve Fizz Buzz with clean code and explore the string-concatenation pattern that avoids nested if-else. Python, Java, C++, and complexity analysis included.
Solve Find Median from Data Stream with two heaps. Learn the balance invariant, why it gives O(log n) inserts and O(1) median, and the common pitfalls.
Solve Jump Game with a single-pass greedy max-reach approach. Compare it against the dynamic programming solution and learn when greedy is provably optimal.
Solve Maximum Product Subarray in linear time by tracking running min and max. Learn why negative numbers flip the role of min and max and see clean code.
Solve Meeting Rooms II two ways: a min-heap of end times and a sweep-line over start and end events. Learn when each shines and how to pick in interviews.
Walk through Merge Intervals step by step. Brute force vs the optimal sort-and-sweep approach, edge cases, and clean code you can ship in an interview.
Detect integer palindromes by reversing half the digits with integer math. Learn why string conversion is discouraged and how to handle negatives and trailing zeros.
Solve the Reverse String problem in place using the two-pointer technique. Walkthrough, complexity analysis, edge cases, and clean Java, Python, and C++ implementations.
Rotate an array by k steps in O(1) extra space using the triple-reverse trick. Compare it with the extra-array approach and learn why this pattern keeps showing up.
A practical guide to backtracking: the recursion template, pruning, classic problems with code, and complexity analysis for subsets and permutations.
Understand Bellman-Ford's relaxation loop, how it handles negative edges, detects negative cycles, and why it costs more than Dijkstra.
Learn Dijkstra's shortest path algorithm with a clean Python implementation, complexity analysis, and the priority queue intuition behind it.
Learn the divide-and-conquer pattern through merge sort and quick sort, recurrence relations, the Master theorem, and how to recognize the pattern.
Implement and understand the Fenwick tree, also called the binary indexed tree, for O(log n) prefix sums and point updates in just a few lines.