encyclopegia.org

Floyd–Rivest algorithm

In computer science, the Floyd–Rivest algorithm is a selection algorithm developed by Robert W.[src] Floyd and Ronald L.[src] Rivest that has an optimal expected number of comparisons within lower-order terms.[src] It is functionally equivalent to quickselect, but runs faster in practice on average.[src] It has an expected running time of and an expected number of comparisons of .[src] The algorithm was originally presented in a 1973 Stanford University technical report containing two papers, where it was referred to as SELECT and paired with PICK, or median of medians.[src] It was subsequently published in Communications of the ACM, volume 18, issue 3.[src]

In computer science, the Floyd–Rivest algorithm is a selection algorithm developed by Robert W. Floyd and Ronald L. Rivest that has an optimal expected number of comparisons within lower-order terms.[src] It is functionally equivalent to quickselect, but runs faster in practice on average.[src] It has an expected running time of and an expected number of comparisons of .[src] The algorithm was originally presented in a 1973 Stanford University technical report containing two papers, where it was referred to as SELECT and paired with PICK, or median of medians.[src] It was subsequently published in Communications of the ACM, volume 18, issue 3.[src] ==Algorithm== The Floyd–Rivest algorithm is a divide-and-conquer algorithm, sharing many similarities with quickselect.[src] It uses sampling to help partition the list into three sets.[src] It then recursively selects the kth smallest element from the appropriate set.[src] The general steps are: Select a small random sample S from the list L.[src] From S, recursively select two elements u and v, such that u 2/3 log 1/3 n), we can get expected comparisons.[src] We can get expected comparisons by starting with a small S and repeatedly updating u and v to keep the size of B small enough (O(n 1/2 log 1/2 n) at Θ(n) processed elements) without unacceptable risk of the desired element being outside of B.[src] ===Pseudocode version=== The following pseudocode rearranges the elements between left and right , such that for some value k, where left ≤ k ≤ right , the kth element in the list will contain the (k − left + 1)th smallest value, with the ith element being less than or equal to the kth for all left ≤ i ≤ k and the jth element being larger or equal to for k ≤ j ≤ right : // left is the left index for the interval // right is the right index for the interval // k is the desired index value, where array[k] is the (k+1)th smallest element when left = 0 function select(array, left, right, k) is while right > left do // Use select recursively to sample a smaller set of size s // the arbitrary constants 600 and 0.5 are used in the original // version to minimize execution time.[src] if right − left > 600 then n := right − left + 1 i := k − left + 1 z := ln(n) s := 0.5 × exp(2 × z/3) sd := 0.5 × sqrt(z × s × (n − s)/n) × sign(i − n/2) newLeft := max(left, k − i × s/n + sd) newRight := min(right, k + (n − i) × s/n + sd) select(array, newLeft, newRight, k) // partition the elements between left and right around t t := array[k] i := left j := right swap array[left] and array[k] if array[right] > t then swap array[right] and array[left] while i t do j := j − 1 if array[left] = t then swap array[left] and array[j] else j := j + 1 swap array[j] and array[right] // Adjust left and right towards the boundaries of the subset // containing the (k − left + 1)th smallest element.[src] if j ≤ k then left := j + 1 if k ≤ j then right := j − 1 ==See also== Quickselect Introselect Median of medians ==References==[src]

21 sentences · 21 cited inline · 0 references stored

References

No reference rows published for this article.

Cite this article

MLA

"Floyd–Rivest algorithm." encyclopegia.org, 2026, https://encyclopegia.org/wiki/floyd-rivest-algorithm. Accessed 29 November 2026.

Chicago

"Floyd–Rivest algorithm." encyclopegia.org. Accessed November 29, 2026. https://encyclopegia.org/wiki/floyd-rivest-algorithm.

APA

encyclopegia.org. (2026). Floyd–Rivest algorithm. Retrieved November 29, 2026, from https://encyclopegia.org/wiki/floyd-rivest-algorithm

Accessed November 29, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

John G. Floyd

stub · references available

μ-law algorithm

stub · references available

John Floyd

stub · references available

Floyd Davis

stub · references available

bitap algorithm

stub · references available

QR algorithm

stub · references available

Prim's algorithm

stub · references available

greedy algorithm

stub · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1375097835 · 0.5 · snapshot enwiki-001375097835

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools
  • Careers — open roles: frontier engineers and sales partners
  • Index — every corpus, paper and record
  • Estate guide — what a public data estate is
  • Founder — Lois-Kleinner Alpasan
  • Records — DOIs and external deposits
  • Documents — one-pagers, PDFs and QR codes
  • Brand kit — logos and share images
  • Papers — plain-language briefs with citations
  • Browser — search engine, PWA and bookmarklet
  • Anticloud — the operator and its projects

As seen in Business Insider · 336 outlets · evidence DOIs · plain-language papers

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.