Table of Contents
Fetching ...

New simple and fast quicksort algorithm for equal keys

Parviz Afereidoon

TL;DR

The paper tackles sorting data with duplicates using quicksort and introduces eqsort, a simple equal-keys partitioning approach with variants that tightly couple partitioning and recursive sorting. By grouping keys equal to the pivot and providing concise implementations (eqsort1/eqsort2/eqsort3), the method achieves strong performance compared with fat partitioning, dual-pivot quicksort, and pdqsort across diverse duplication levels. Experimental results show eqsort is consistently competitive, often faster, and provides favorable comparisons-swaps trade-offs, especially on real-world data. This work suggests eqsort could replace or augment existing partitioning strategies in practical sorting libraries for datasets with many duplicates.

Abstract

This paper introduces a novel and efficient partitioning technique for quicksort, specifically designed for real-world data with duplicate elements (50-year-old problem). The method is referred to as "equal quicksort" or "eqsort". Based on the experimental findings, it has been determined that the newly developed algorithm, eqsort, is competitive with the best current implementations,such as fat partitioning algorithms and dual-pivot quicksort. This method offers several advantages over the commonly used dual-pivot method and pdqsort partitioning, making it a potential replacement.

New simple and fast quicksort algorithm for equal keys

TL;DR

The paper tackles sorting data with duplicates using quicksort and introduces eqsort, a simple equal-keys partitioning approach with variants that tightly couple partitioning and recursive sorting. By grouping keys equal to the pivot and providing concise implementations (eqsort1/eqsort2/eqsort3), the method achieves strong performance compared with fat partitioning, dual-pivot quicksort, and pdqsort across diverse duplication levels. Experimental results show eqsort is consistently competitive, often faster, and provides favorable comparisons-swaps trade-offs, especially on real-world data. This work suggests eqsort could replace or augment existing partitioning strategies in practical sorting libraries for datasets with many duplicates.

Abstract

This paper introduces a novel and efficient partitioning technique for quicksort, specifically designed for real-world data with duplicate elements (50-year-old problem). The method is referred to as "equal quicksort" or "eqsort". Based on the experimental findings, it has been determined that the newly developed algorithm, eqsort, is competitive with the best current implementations,such as fat partitioning algorithms and dual-pivot quicksort. This method offers several advantages over the commonly used dual-pivot method and pdqsort partitioning, making it a potential replacement.

Paper Structure

This paper contains 6 sections, 5 figures.

Figures (5)

  • Figure 1: Example of how eqsort2 sorts elements of an array. In the example we use the first element as the pivot but it could be any other element by swapping it with first element. In this example, the first element (3) is selected as the pivot, the right sub-array contains all the elements greater than three and equal to three, and the left sub-array is empty, which is exit in the second step. Before entering the right sub-array, the while loop is executed. Since the first number is 3 and the pivot of this step is 3, it passes through it and for the remaining data, the first element 19 is selected as the pivot and this cycle is repeated.
  • Figure 2: (a): Runtime (in second) for dataset of size $10^{6}$ for increasing number of distinct elements. (b): Runtime ratio for dual-pivot , pdqsort and eqsort methods
  • Figure 3: Comparisons and swaps ratio for dual-pivot , pdqsort and eqsort1 methods.
  • Figure 4: (a): Runtime (in second) for dataset of size $10^{5}$ for increasing number of distinct elements. (b): Runtime ratio for dual-pivot , pdqsort , eqsort1 ,eqsort2 and eqsort3 methods
  • Figure 5: (a): Runtime (in second) for dataset of size $10^{4}$ for increasing number of distinct elements. (b): Runtime ratio for dual-pivot , pdqsort , eqsort1 and eqsort3 methods