Short answer: RSA builds a public modulus n as a product of two secret primes and a public exponent e that is coprime to λ(n), the Carmichael function of n. The private exponent d is the modular inverse of e modulo λ(n). Encryption of an integer m in 0…
How round-robin shares a processor by a quantum
Short answer: Round-robin scheduling runs the job at the head of a ready queue for a fixed quantum, then moves it to the tail if it is still ready. With n jobs continuously ready, a quantum q, and a context switch of length s, each job waits at most…
How rotating calipers walk antipodal pairs
Short answer: Rotating calipers compute the diameter, the width, and several other extents of a convex polygon by walking two parallel supporting lines around the boundary. The lines start on an antipodal pair, often the leftmost and rightmost vertices, and the one that can rotate less before it hits…
How reservoir sampling keeps a uniform subset
Short answer: Reservoir sampling draws k items uniformly from a stream of unknown length. The first k items fill the reservoir. When item i arrives, with i counted from 1, it replaces a random reservoir slot with probability k/i. Algorithm R uses one random number per item and O(k)…
How rendezvous hashing picks the highest score
Short answer: Rendezvous hashing, or highest random weight, places a key on the node that maximizes a hash of the key mixed with the node id. Every node computes the same scores, so every client agrees. Adding or removing a node moves only the keys for which that node…
How ray casting tests a point in a polygon
Short answer: Ray casting decides whether a point lies inside a simple polygon by shooting a horizontal ray to infinity and counting edge crossings. An odd count means inside. An even count means outside. Vertices that lie on the ray are counted under a rule that treats an edge…
How rate-monotonic scheduling assigns fixed priorities
Short answer: Rate-monotonic scheduling gives a periodic task a fixed priority by its period: a shorter period gets a higher priority. On one preemptive processor, with implicit deadlines and independent tasks, a utilization at most n(2^{1/n} − 1) is a sufficient schedulability test. The bound falls toward ln 2,…
How RANSAC fits a model to inliers
Short answer: RANSAC fits a geometric model when many points are outliers. It draws the smallest sample that determines the model, fits, and counts how many points agree within a threshold. After enough trials it refits on the largest inlier set. The number of trials needed to see at…
How radix sort orders keys one digit at a time
Short answer: LSD radix sort stable-sorts fixed-width keys from the least significant digit to the most significant. Each digit is a counting sort on a radix-r alphabet. With d digits the time is Θ(d(n+r)). Sorting the least significant digit first is what makes a later digit pass keep the…
How Rabin-Karp rolls a hash across the text
Short answer: Rabin-Karp hashes the pattern and every window of the text. A polynomial rolling hash updates the next window in constant time: subtract the outgoing character, multiply by the radix, and add the incoming character, all modulo a prime. Equal hashes are candidates and must be verified character…
How quicksort recurses after a partition
Short answer: Quicksort partitions a slice around a pivot and sorts the two sides. With Lomuto’s partition the pivot ends at its final index and is excluded from both recursive calls. With Hoare’s partition the cut index is only a boundary between small keys and large keys, and the…
How quickselect finds one order statistic
Short answer: Quickselect partitions around a pivot and recurses into the only side that still contains rank k. A partition that places the pivot at its final index answers immediately when that index equals k. The expected cost with a random pivot is Θ(n). A pivot that always leaves…
How push-relabel moves preflow downhill
Short answer: Push-relabel maintains a preflow: every vertex except the source may hold excess, and no residual edge runs from a higher label to a lower one except when the algorithm is mid-push. A vertex with excess pushes flow along a residual edge to a neighbor labeled exactly one…
How Prim grows a minimum spanning tree from a cut
Short answer: Prim’s algorithm grows one tree. The lightest edge with one end in the tree and one end outside it is safe to add, by the cut property. A binary heap implements the fringe in O((V+E) log V). A Fibonacci heap improves the proof to O(E + V…
How prefix doubling builds a suffix array
Short answer: A suffix array is the starting positions of all suffixes of a string, sorted in lexicographic order. Prefix doubling sorts those suffixes by the first character, then by the first 2, 4, 8, … characters, using the ranks from the previous round as a pair key. Each…
How power iteration extracts a dominant eigenvalue
Short answer: Power iteration estimates the dominant eigenvector of a matrix by repeating x ← Ax and normalizing. If one eigenvalue is strictly larger in magnitude than the others, the direction of x converges to that eigenvector and the Rayleigh quotient converges to the eigenvalue. The error shrinks by…
How Pollard’s rho hunts a factor on a cycle
Short answer: Pollard’s rho looks for a nontrivial factor of a composite n by iterating a polynomial, usually x² + c, modulo n, and taking gcd of n with the difference of two values on the sequence. By the birthday paradox the sequence cycles quickly modulo a secret prime…
How Peterson’s algorithm locks two threads
Short answer: Peterson’s algorithm gives two threads mutual exclusion with three shared variables: a flag for each thread and a single turn. A thread raises its flag, gives the turn to the other thread, and waits while the other flag is up and the turn still belongs to the…
