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

public class BubbleSortStrategy extends Object implements SortStrategy
Implements the bubble sort algorithm as a sorting strategy.

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

      Summary of bubble sort algorithm: Bubble sort repeatedly compares adjacent elements, swapping them if they are out of order. The process continues until no swaps are needed in a complete pass, indicating a sorted array.

      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.