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

public class MergeSortStrategy extends Object implements SortStrategy
Implements the merge sort algorithm as a sorting strategy.

This class implements the SortStrategy interface and provides a method to perform merge 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 merge sort algorithm.

      Merge sort is a divide-and-conquer algorithm that recursively divides the array into single-element subarrays. These subarrays are then merged pairwise to produce the sorted result.

      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:
      The sorted array.