Lucky Cars and the Quicksort Algorithm

From MaRDI portal



Abstract: Quicksort is a classical divide-and-conquer sorting algorithm. It is a comparison sort that makes an average of 2(n+1)Hn−4n comparisons on an array of size n ordered uniformly at random, where Hn=sumi=1nfrac1i is the nth harmonic number. Therefore, it makes n!left[2(n+1)Hn−4night] comparisons to sort all possible orderings of the array. In this article, we prove that this count also enumerates the parking preference lists of n cars parking on a one-way street with n parking spots resulting in exactly n−1 lucky cars (i.e., cars that park in their preferred spot). For ngeq2, both counts satisfy the second order recurrence relation fn=2nfn−1−n(n−1)fn−2+2(n−1)! with f0=f1=0.












This page was built for publication: Lucky Cars and the Quicksort Algorithm

Report a bug (only for logged in users!)Click here to report a bug for this page (MaRDI item Q6441155)