docs: update the whole repository

* fix some bugs
* delete duplicate files
* format code
This commit is contained in:
yanglbme
2019-05-09 19:32:54 +08:00
parent 163db8521a
commit 29948363da
368 changed files with 4372 additions and 30841 deletions

View File

@@ -4,26 +4,23 @@ import java.util.Random;
/**
*
* @author Podshivalov Nikita (https://github.com/nikitap492)
*
* @see SortAlgorithm
*
*/
public class BogoSort implements SortAlgorithm {
private static final Random random = new Random();
private static <T extends Comparable<T>> boolean isSorted(T array[]){
for(int i = 0; i<array.length - 1; i++){
if(SortUtils.less(array[i + 1], array[i])) return false;
private static <T extends Comparable<T>> boolean isSorted(T array[]) {
for (int i = 0; i < array.length - 1; i++) {
if (SortUtils.less(array[i + 1], array[i])) return false;
}
return true;
}
// Randomly shuffles the array
private static <T> void nextPermutation(T array[]){
private static <T> void nextPermutation(T array[]) {
int length = array.length;
for (int i = 0; i < array.length; i++) {
@@ -33,7 +30,7 @@ public class BogoSort implements SortAlgorithm {
}
public <T extends Comparable<T>> T[] sort(T array[]) {
while(!isSorted(array)){
while (!isSorted(array)) {
nextPermutation(array);
}
return array;
@@ -50,7 +47,7 @@ public class BogoSort implements SortAlgorithm {
SortUtils.print(bogoSort.sort(integers));
// String Input
String[] strings = {"c", "a", "e", "b","d"};
String[] strings = {"c", "a", "e", "b", "d"};
SortUtils.print(bogoSort.sort(strings));
}