Skip to content

Commit e5dbbe2

Browse files
authored
Merge pull request kelvins#192 from AmanRawat33/patch-1
Update BogoSort.java
2 parents b35f859 + bb7159d commit e5dbbe2

File tree

1 file changed

+42
-42
lines changed

1 file changed

+42
-42
lines changed

src/java/BogoSort.java

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,26 @@
55
public class BogoSort {
66

77
/**
8-
* @param vetor
8+
* @param vector
99
*/
10-
public int[] sort(int[] vetor) {
11-
// Verifica se o vetor está ordenado
12-
while (!isSorted(vetor)) {
13-
// Embaralha o vetor pra tentar ordenar aleatoriamente
14-
shuffle(vetor);
10+
public int[] sort(int[] vector) {
11+
// Checking if the vector is ordered
12+
while (!isSorted(vector)) {
13+
// Shuffle the vector to try to sort it randomly
14+
shuffle(vector);
1515
}
16-
return vetor;
16+
return vector;
1717
}
1818

1919
/**
20-
* Verifica se o vetor está ordenado
20+
* Checking again if the vector is ordered
2121
*
22-
* @param vetor
22+
* @param vector
2323
* @return
2424
*/
25-
private static boolean isSorted(int[] vetor) {
26-
for (int i = 0; i < (vetor.length - 1); ++i) {
27-
if (vetor[i] > vetor[i + 1]) {
25+
private static boolean isSorted(int[] vector) {
26+
for (int i = 0; i < (vector.length - 1); ++i) {
27+
if (vector[i] > vector[i + 1]) {
2828
return false;
2929
}
3030
}
@@ -33,17 +33,17 @@ private static boolean isSorted(int[] vetor) {
3333
}
3434

3535
/**
36-
* Embaralha o vetor pra tentar ordenar aleatoriamente
36+
* Shuffle the vector to try to sort it randomly
3737
*
38-
* @param vetor Vetor a ser ordenado
38+
* @param vector Vector is to be sorted
3939
*/
40-
private static void shuffle(int[] vetor) {
41-
for (int x = 0; x < vetor.length; ++x) {
42-
int index1 = (int) (Math.random() * vetor.length),
43-
index2 = (int) (Math.random() * vetor.length);
44-
int a = vetor[index1];
45-
vetor[index1] = vetor[index2];
46-
vetor[index2] = a;
40+
private static void shuffle(int[] vector) {
41+
for (int x = 0; x < vector.length; ++x) {
42+
int index1 = (int) (Math.random() * vector.length),
43+
index2 = (int) (Math.random() * vector.length);
44+
int a = vector[index1];
45+
vector[index1] = vector[index2];
46+
vector[index2] = a;
4747
}
4848
}
4949
}
@@ -54,26 +54,26 @@ private static void shuffle(int[] vetor) {
5454
public class BogoSort {
5555

5656
/**
57-
* @param vetor
57+
* @param vector
5858
*/
59-
public int[] sort(int[] vetor) {
60-
// Verifica se o vetor está ordenado
61-
while (!isSorted(vetor)) {
62-
// Embaralha o vetor pra tentar ordenar aleatoriamente
63-
shuffle(vetor);
59+
public int[] sort(int[] vector) {
60+
// Verify if the vector is ordered
61+
while (!isSorted(vector)) {
62+
// Shuffle the vector to try to sort it randomly
63+
shuffle(vector);
6464
}
65-
return vetor;
65+
return vector;
6666
}
6767

6868
/**
69-
* Verifica se o vetor está ordenado
69+
* Verify if the vector (named vector) is sorted
7070
*
71-
* @param vetor
71+
* @param vector
7272
* @return
7373
*/
74-
private static boolean isSorted(int[] vetor) {
75-
for (int i = 0; i < (vetor.length - 1); ++i) {
76-
if (vetor[i] > vetor[i + 1]) {
74+
private static boolean isSorted(int[] vector) {
75+
for (int i = 0; i < (vector.length - 1); ++i) {
76+
if (vector[i] > vector[i + 1]) {
7777
return false;
7878
}
7979
}
@@ -82,17 +82,17 @@ private static boolean isSorted(int[] vetor) {
8282
}
8383

8484
/**
85-
* Embaralha o vetor pra tentar ordenar aleatoriamente
85+
* Shuffle the vector to try to sort it randomly
8686
*
87-
* @param vetor Vetor a ser ordenado
87+
* @param vector Vector is to be sorted
8888
*/
89-
private static void shuffle(int[] vetor) {
90-
for (int x = 0; x < vetor.length; ++x) {
91-
int index1 = (int) (Math.random() * vetor.length),
92-
index2 = (int) (Math.random() * vetor.length);
93-
int a = vetor[index1];
94-
vetor[index1] = vetor[index2];
95-
vetor[index2] = a;
89+
private static void shuffle(int[] vector) {
90+
for (int x = 0; x < vector.length; ++x) {
91+
int index1 = (int) (Math.random() * vector.length),
92+
index2 = (int) (Math.random() * vector.length);
93+
int a = vector[index1];
94+
vector[index1] = vector[index2];
95+
vector[index2] = a;
9696
}
9797
}
9898
}

0 commit comments

Comments
 (0)