Because of unmatched improvements in CPU performance, memory transfers have become a bottleneck of program execution. As discovered in recent years, this also affects sorting in internal memory. Since partitioning around several pivots reduces overall memory transfers, we have seen renewed interest in multiway Quicksort. Here, we analyze in how far multiway partitioning helps in Quickselect.We compute the expected number of comparisons and scanned elements (approximating memory transfers) for a generic class of (non-adaptive) multiway Quickselect and show that three or more pivots are not helpful, but two pivots are. Moreover, we consider "adaptive" variants which choose partitioning and pivot-selection methods in each recursive step from a finite set of alternatives depending on the current (relative) sought rank. We show that "Sesquickselect", a new Quickselect variant that uses either one or two pivots, makes better use of small samples w.r.t. memory transfers than other Quickselect variants. After the Latin prefix sesqui-meaning "one and a half".
Preliminaries3 Unfortunately, the grand-average analysis does not extend to adaptive methods like Sesquickselect. For the second part, we hence consider selecting the α-quantile in a large array for a fixed α ∈ (0, 1) (extending techniques from [29]). We give an elementary proof for the correctness of a resulting integral equation for the leading-term coefficient as a function of α (under reasonable assumptions fulfilled for our applications) that appears to be novel.The setting with two parameters makes computations appreciably more challenging. For Quickselect with YBB partitioning (without pivot sampling) and Sesquickselect with k = 2 we solve the integral equations analytically, and we obtain precise numerical solutions for more general cases. From these, we can derive promising candidates of cache-optimal Quickselect variants for all practical sample sizes.Outline. We give an overview of previous work in the remainder of this section. § 2 introduces notation and preliminaries. In § 3, we state a general distributional recurrence of costs. § 4 discusses the analysis for random ranks. We then switch to fixed ranks and derive the integral equation in § 5. We solve it for Quickselect with YBB-partitioning ( § 6) and for the novel "Sesquickselect" algorithm ( § 7). Our paper concludes with a discussion of our findings ( § 8).The appendix contains a comprehensive list of notation, as well as some technical proofs and details of the computations.
Previous WorkThe first published analysis of (classic) Quickselect by Knuth served as one of two illustrating examples in an invited address at the IFIP Congress 1971, with the goal to advertise the emerging area of analysis of algorithms [24,25]. The expected number of comparisons in classic Quickselect is E[C n,m ] = 2 (n + 1)i . An asymptotic approximation for selecting the α-quantile, α ∈ (0, 1) fixed, follows with m = αn: E[C n,αn ] = 2(h(α)+1)·n−8 ln n±O(1), n → ∞, where h(x) = −x ln x−(1−x) ln(1−x); (here we set 0 ln 0 ...