Package algorithmcomparison
Class Bogosort
java.lang.Object
algorithmcomparison.Bogosort
Bogosort
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Bogosort
public Bogosort()
-
-
Method Details
-
bogosort
public static int[] bogosort(int[] arr) Sorts the array using Bogosort- Parameters:
arr- The unsorted dataset- Returns:
- sorted The sorted dataset
-
shuffle
public static void shuffle(int[] a) Shuffles the array- Parameters:
a- The unsorted array
-
swap
public static void swap(int[] a, int i, int j) Swaps two array elements- Parameters:
a- The array that is being sortedi- The index of the element that is swappedj- The index of the element that is swapped
-
isSorted
public static boolean isSorted(int[] a) Checks if the array is sorted- Parameters:
a- The unsorted or sorted array- Returns:
- true or false
-