Conceptio › Archive › Stack Exchange
Stack Exchange open access CC BY-SA

Quicksort Partitioning: Hoare vs. Lomuto

Robert S. Barnes · 2013
Stack Exchange · Datasets · License: CC BY-SA · 2013
Open Source ↗
algorithmscssorting
There are two quicksort partition methods mentioned in Cormen: (the argument A is the array, and [p, r] is the range, inclusive, to perform the partition on. The returned value is the index to the pivot after the partition.) Hoare-Partition(A, p, r) x = A[p] i = p - 1 j = r + 1 while true repeat j = j - 1 until A[j] = x if i < j swap( A[i], A[j] ) else return j and: Lomuto-Partition(A, p, r) x = A[r] i = p - 1 for j = p to r - 1 if A[j] <= x i = i + 1 swap( A[i], A[j] ) swap( A[i + 1], A[r] ) return i + 1 Disregarding the method of choosing the pivot, in what situations is one preferable to the other? I know for instance that Lomuto preforms relatively poorly when there is a high percentage of duplicate values ( i.e. where say more than 2/3rds the array is the same value ), whereas Hoare performs just fine in that situation. What other special cases make one partition method significant better than the other?
Conceptio Open Archive

Analyze & explore related research in Conceptio

Connect this record directly into your research workflow or AI agent. Explore citations across open repositories, query full text, and export structured proof bundles.

This document is indexed with metadata only: full text is not available in the archive for this record. Open the official source ↗

Related documents

Record · ID 796537
Retrieved via Conceptio: every document is proof-bundled with source, license, and retrieval metadata.
Bring this data into your agent: Connect via MCP or API · 20 free credits to start · no card required
Read the Docs → · View CLI source on GitHub · Conceptio Open Knowledge Archive