java.lang.Object
com.github.rlacher.sortbench.strategies.implementations.QuickSortStrategy
All Implemented Interfaces:
SortStrategy

public class QuickSortStrategy extends Object implements SortStrategy
Implements the quick sort algorithm as a sorting strategy.

This class implements the SortStrategy interface and provides a method to perform quick sort on an array of integers.

  • Constructor Details

  • Method Details

    • sort

      public BenchmarkMetric sort(int[] array)
      Sorts the provided array in ascending order using the quick sort algorithm.

      Summary of quick sort algorithm: Quicksort, using the first element as the pivot, partitions the array such that elements smaller than the pivot are on the left and equal or larger elements are on the right. The pivot is then swapped to its correct sorted position between these partitions. The algorithm recursively sorts the left and right subarrays until they contain zero or one element.

      Input array validation is assumed to be performed by the calling Sorter class.

      Specified by:
      sort in interface SortStrategy
      Parameters:
      array - The array to be sorted.
      Returns:
      A BenchmarkMetric containing performance information about the sorting process.
      Throws:
      NullPointerException - If array is null (though this should be prevented by the caller).