Skip to content

Commit fa93c62

Browse files
committed
feat: 버블 정렬 구현
1 parent 775f47c commit fa93c62

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package sort;
2+
3+
public class BubbleSort implements Sort {
4+
5+
@Override
6+
public void sort(int[] array) {
7+
int length = array.length;
8+
int temp;
9+
for (int i = 0; i < length - 1; i++) {
10+
for (int j = 0; j < length - i - 1; j++) {
11+
if (array[j] > array[j + 1]) {
12+
temp = array[j];
13+
array[j] = array[j + 1];
14+
array[j + 1] = temp;
15+
}
16+
}
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)