brain

tamnd's digital brain — notes, problems, research

43815 notes

19.7 Skip Lists Revisited

Balanced search trees achieve logarithmic performance by carefully maintaining structural invariants.

algorithmsrandomizedapproximation
19.2 Las Vegas Algorithms

A randomized algorithm can use randomness in several ways.

algorithmsrandomizedapproximation
19.19 Online Algorithms

Most algorithms assume complete knowledge of the input before computation begins.

algorithmsrandomizedapproximation
19.9 MinHash

Many large-scale systems need to compare sets.

algorithmsrandomizedapproximation
19.3 Monte Carlo Algorithms

Las Vegas algorithms always return correct answers and use randomness to influence resource consumption.

algorithmsrandomizedapproximation
19.22 Probability Bounds

Randomized algorithms rarely stop at computing an expected value.

algorithmsrandomizedapproximation
19.4 Randomized Quicksort

Randomized quicksort is one of the most successful applications of randomization in algorithm design.

algorithmsrandomizedapproximation
19.18 Primal-Dual Approximation

Primal-dual approximation algorithms use linear programming structure to design fast approximate solutions.

algorithmsrandomizedapproximation
19.6 Shuffling

Shuffling converts an ordered collection into a uniformly random permutation.

algorithmsrandomizedapproximation
19.25 Choosing the Right Randomized Technique

Randomized algorithms span a wide range of techniques.

algorithmsrandomizedapproximation
19.8 Hashing with Randomness

Hash tables are usually presented as deterministic data structures: compute a hash, reduce it to a table index, and store or retrieve the key.

algorithmsrandomizedapproximation
19.20 Streaming Algorithms

Streaming algorithms process data one item at a time while using much less memory than the input size.

algorithmsrandomizedapproximation
19.24 Randomized Algorithms in Practice

Theoretical analysis explains why randomized algorithms work.

algorithmsrandomizedapproximation
19.16 Set Cover Approximation

Set Cover is the canonical greedy approximation problem.

algorithmsrandomizedapproximation
19.17 Randomized Rounding

Many optimization problems can be expressed as integer programs.

algorithmsrandomizedapproximation
19.23 Derandomization

Randomized algorithms are often easier to design and analyze than deterministic algorithms.

algorithmsrandomizedapproximation
19.14 Approximation Ratios

Some optimization problems are easy to state and hard to solve exactly.

algorithmsrandomizedapproximation
19.5 Random Sampling

Random sampling is one of the most powerful techniques in algorithm design.

algorithmsrandomizedapproximation
19.10 HyperLogLog

HyperLogLog estimates the number of distinct elements in a stream using a small, fixed amount of memory.

algorithmsrandomizedapproximation
19.13 Locality-Sensitive Hashing

Many applications need to find similar items inside very large collections.

algorithmsrandomizedapproximation
19.11 Bloom Filters Revisited

A Bloom filter is one of the most widely deployed probabilistic data structures in modern computing.

algorithmsrandomizedapproximation
19.1 Random Variables in Algorithms

Randomized algorithms differ from deterministic algorithms because their behavior depends on random choices made during execution.

algorithmsrandomizedapproximation
19.21 The Power of Randomization

Throughout this chapter, we have encountered a recurring theme: ```text A small amount of randomness can dramatically simplify

algorithmsrandomizedapproximation
18.8 Sieve of Eratosthenes

The Sieve of Eratosthenes is the standard algorithm for generating all primes up to a limit.

algorithmsnumber-theorymathematics
18.13 Modular Combinatorics

Many counting problems ask for results modulo a large number.

algorithmsnumber-theorymathematics
18.7 Primality Testing

Prime numbers occupy a central position in number theory.

algorithmsnumber-theorymathematics
18.20 Pollard's Rho Factorization

Primality testing tells us whether a number is prime.

algorithmsnumber-theorymathematics
18.10 Chinese Remainder Theorem

The Chinese Remainder Theorem is a reconstruction tool.

algorithmsnumber-theorymathematics
18.12 Euler's Theorem and Fermat's Little Theorem

Many algorithms require computing enormous powers modulo an integer.

algorithmsnumber-theorymathematics
18.15 Linear Congruences

A linear congruence is the modular analogue of a linear equation.

algorithmsnumber-theorymathematics
18.23 Complexity Analysis

Number theory algorithms often look fast because their code is short.

algorithmsnumber-theorymathematics
18.14 Möbius Function and Möbius Inversion

Many counting problems involve inclusion-exclusion.

algorithmsnumber-theorymathematics
18.21 Big Integer Concerns

Number-theoretic algorithms often look simple when written with mathematical notation.

algorithmsnumber-theorymathematics
18.18 Discrete Logarithms

Ordinary logarithms answer the question: ```text a^x = b ```

algorithmsnumber-theorymathematics
18.6 Fast Exponentiation

Exponentiation appears constantly in number-theoretic algorithms.

algorithmsnumber-theorymathematics
18.2 Euclidean Algorithm

The Euclidean Algorithm is one of the oldest known algorithms and remains one of the most useful.

algorithmsnumber-theorymathematics
18.3 Extended Euclidean Algorithm

The Euclidean Algorithm computes the greatest common divisor of two integers.

algorithmsnumber-theorymathematics
18.22 Practical Number Theory Patterns

Throughout this chapter we studied individual algorithms: - Euclidean Algorithm - Modular Arithmetic - Fast Exponentiation

algorithmsnumber-theorymathematics
18.11 Euler Phi Function

Euler's phi function counts how many numbers in a range are coprime to a given integer.

algorithmsnumber-theorymathematics
18.25 Number Theory Toolkit

After working through the algorithms in this chapter, it is useful to step back and assemble them into a practical toolkit.

algorithmsnumber-theorymathematics
18.16 Diophantine Equations

A Diophantine equation is an equation whose solutions must be integers.

algorithmsnumber-theorymathematics
18.24 Testing Number-Theoretic Code

Number-theoretic code is compact, but its edge cases are dense.

algorithmsnumber-theorymathematics
18.9 Factorization

Many number-theoretic algorithms become simpler once a number is expressed as a product of primes.

algorithmsnumber-theorymathematics
18.17 Primitive Roots

Primitive roots describe generators of modular multiplication.

algorithmsnumber-theorymathematics
18.1 Divisibility

Divisibility is one of the most fundamental concepts in number theory.

algorithmsnumber-theorymathematics
18.5 Modular Inverse

Division is one of the most subtle operations in modular arithmetic.

algorithmsnumber-theorymathematics
18.19 Miller-Rabin Primality Test

The Miller-Rabin test is the practical standard for fast primality testing.

algorithmsnumber-theorymathematics
18.4 Modular Arithmetic

Modular arithmetic is the arithmetic of remainders.

algorithmsnumber-theorymathematics
17.9 Sweep Line Algorithms

Many geometric problems involve detecting interactions among large collections of geometric objects.

algorithmsgeometry
17.14 Delaunay Triangulation Overview

Given a set of points in the plane, construct a triangulation that avoids thin, poorly shaped triangles as much as possible.

algorithmsgeometry
17.11 Rectangle Union Area

Given a set of axis-aligned rectangles, compute the total area covered by their union.

algorithmsgeometry
17.19 Spatial Indexes

You need to search large collections of geometric objects efficiently.

algorithmsgeometry
17.15 Precision Errors

Geometric algorithms often look exact on paper but fail in code because numeric computations are approximate.

algorithmsgeometry
17.5 Point in Polygon

Given a polygon and a query point, determine whether the point lies: ```text inside the polygon outside the polygon

algorithmsgeometry
17.16 Integer Geometry

Many computational geometry problems use coordinates that are naturally integers: ```text grid maps pixels

algorithmsgeometry
17.24 Performance Optimization

Many geometric algorithms are already asymptotically optimal.

algorithmsgeometry
17.21 Geometry Design Patterns

After studying individual geometric algorithms, it is tempting to view them as unrelated techniques.

algorithmsgeometry
17.1 Points and Vectors

You need a mathematical representation for locations, directions, distances, and geometric relationships.

algorithmsgeometry
17.3 Line and Segment Intersection

Given two lines or two line segments, determine whether they intersect and, if they do, compute the intersection point.

algorithmsgeometry
17.12 Half-Plane Intersection

Given a collection of half-planes, compute their common intersection.

algorithmsgeometry
17.25 Case Studies

Individual geometry algorithms are useful, but real systems usually require several of them working together.

algorithmsgeometry
17.22 Correctness Proofs

Geometric algorithms are easy to test visually and surprisingly easy to get wrong.

algorithmsgeometry
17.17 Floating-Point Robustness

Some geometric problems cannot stay entirely in integer arithmetic.

algorithmsgeometry
17.2 Orientation Tests

Many geometric algorithms must determine whether three points form a left turn, a right turn, or lie on the same line.

algorithmsgeometry
17.13 Voronoi Diagrams Overview

Given a set of points, partition the plane into regions so that every location belongs to the region of its nearest point.

algorithmsgeometry
17.6 Convex Hull

Given a set of points, compute the smallest convex polygon that contains all of them.

algorithmsgeometry
17.7 Rotating Calipers

After constructing a convex hull, many geometric questions remain: * What is the maximum distance between any two points?

algorithmsgeometry
17.20 Geometry Libraries and Practical Patterns

Most real-world geometry software is not built from a single algorithm.

algorithmsgeometry
17.10 Interval Geometry

You need to solve geometric problems that can be reduced to one-dimensional intervals.

algorithmsgeometry
17.18 Geometric Hashing

You need a fast way to group or search geometric objects by location.

algorithmsgeometry
17.8 Closest Pair of Points

Given a set of points in the plane, find the pair with the smallest Euclidean distance.

algorithmsgeometry
17.23 Testing Geometry Algorithms

Geometry code fails in ways that ordinary examples rarely expose.

algorithmsgeometry
17.4 Polygon Area

Given a polygon described by its vertices, compute its area efficiently and accurately.

algorithmsgeometry
16.16 String Hashing

Many string algorithms repeatedly compare substrings.

algorithmsstringspattern-matching
16.25 Real-World String Processing Patterns

After learning dozens of string algorithms, a natural question remains: > What do real systems actually do?

algorithmsstringspattern-matching
16.3 Z Algorithm

Many string algorithms need to answer the question: > How many characters match between a string prefix and a substring starting at a particular position?

algorithmsstringspattern-matching
16.18 Unicode and Normalization

Many string algorithms assume that a string is simply a sequence of characters.

algorithmsstringspattern-matching
16.15 Lexicographic Order

Many string algorithms depend on a precise ordering of strings.

algorithmsstringspattern-matching
16.22 Building a Search Engine

Throughout this chapter, we studied individual string-processing techniques: - Tokenization - Tries - Hashing

algorithmsstringspattern-matching
16.20 Choosing the Right String Algorithm

This chapter introduced a large collection of string-processing techniques: - Naive matching - KMP - Z Algorithm

algorithmsstringspattern-matching
16.24 Testing String Algorithms

String algorithms are easy to implement incorrectly.

algorithmsstringspattern-matching
16.10 Suffix Automata

Suppose you need to answer questions such as: - Does a substring occur in the text?

algorithmsstringspattern-matching
16.12 Manacher Algorithm

You need to find palindromic substrings efficiently.

algorithmsstringspattern-matching
16.8 Suffix Arrays

Suppose you need to answer many substring queries against the same text.

algorithmsstringspattern-matching
16.4 Rabin-Karp

Suppose you need to search for a pattern inside a large text.

algorithmsstringspattern-matching
16.14 Longest Common Substring

Given two strings, find the longest contiguous block of characters that appears in both.

algorithmsstringspattern-matching
16.21 Text Indexing

A single pattern search scans one text once.

algorithmsstringspattern-matching
16.7 Aho-Corasick

Suppose you need to search a text for thousands of patterns simultaneously.

algorithmsstringspattern-matching
16.9 Longest Common Prefix (LCP) Arrays

In the previous recipe, you built a suffix array and used it to perform efficient substring searches.

algorithmsstringspattern-matching
16.6 Trie Matching

Suppose you need to search for many patterns simultaneously.

algorithmsstringspattern-matching
16.23 Complexity Analysis

String algorithms often look deceptively simple.

algorithmsstringspattern-matching
16.19 Token Streams

Most string algorithms operate on characters.

algorithmsstringspattern-matching
16.17 Compressed Strings

Many strings contain repeated structure.

algorithmsstringspattern-matching
16.5 Boyer-Moore Overview

Most exact matching algorithms process the text from left to right.

algorithmsstringspattern-matching
16.2 Knuth-Morris-Pratt (KMP)

The naive exact matching algorithm repeatedly compares the same characters after every mismatch.

algorithmsstringspattern-matching
16.1 Exact Matching

Given a text string and a pattern string, determine whether the pattern occurs in the text and, if so, find all positions where the match begins.

algorithmsstringspattern-matching
16.11 Palindromic Trees (Eertrees)

Many string algorithms focus on prefixes, suffixes, or arbitrary substrings.

algorithmsstringspattern-matching
16.13 Edit Distance

Exact matching assumes that strings must be identical.

algorithmsstringspattern-matching
15.22 Common Bugs

Divide-and-conquer algorithms often fail in ways that are difficult to see from the high-level design.

algorithmsdivide-and-conquerrecursion
15.6 Karatsuba Multiplication

You need to multiply very large integers.

algorithmsdivide-and-conquerrecursion