mirror of
https://github.com/TheAlgorithms/Java.git
synced 2026-03-13 08:40:43 +08:00
docs: update the whole repository
* fix some bugs * delete duplicate files * format code
This commit is contained in:
@@ -1,20 +1,18 @@
|
||||
package Sorts;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Mateus Bizzo (https://github.com/MattBizzo)
|
||||
* @author Podshivalov Nikita (https://github.com/nikitap492)
|
||||
*
|
||||
*/
|
||||
|
||||
class CocktailShakerSort implements SortAlgorithm {
|
||||
|
||||
/**
|
||||
* This method implements the Generic Cocktail Shaker Sort
|
||||
*
|
||||
* @param array The array to be sorted
|
||||
* Sorts the array in increasing order
|
||||
**/
|
||||
/**
|
||||
* This method implements the Generic Cocktail Shaker Sort
|
||||
*
|
||||
* @param array The array to be sorted
|
||||
* Sorts the array in increasing order
|
||||
**/
|
||||
|
||||
@Override
|
||||
public <T extends Comparable<T>> T[] sort(T[] array) {
|
||||
@@ -47,19 +45,19 @@ class CocktailShakerSort implements SortAlgorithm {
|
||||
|
||||
}
|
||||
|
||||
// Driver Program
|
||||
public static void main(String[] args) {
|
||||
// Integer Input
|
||||
Integer[] integers = { 4, 23, 6, 78, 1, 54, 231, 9, 12 };
|
||||
CocktailShakerSort shakerSort = new CocktailShakerSort();
|
||||
// Driver Program
|
||||
public static void main(String[] args) {
|
||||
// Integer Input
|
||||
Integer[] integers = {4, 23, 6, 78, 1, 54, 231, 9, 12};
|
||||
CocktailShakerSort shakerSort = new CocktailShakerSort();
|
||||
|
||||
// Output => 1 4 6 9 12 23 54 78 231
|
||||
SortUtils.print(shakerSort.sort(integers));
|
||||
// Output => 1 4 6 9 12 23 54 78 231
|
||||
SortUtils.print(shakerSort.sort(integers));
|
||||
|
||||
// String Input
|
||||
String[] strings = { "c", "a", "e", "b", "d" };
|
||||
SortUtils.print(shakerSort.sort(strings));
|
||||
}
|
||||
// String Input
|
||||
String[] strings = {"c", "a", "e", "b", "d"};
|
||||
SortUtils.print(shakerSort.sort(strings));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user