Last active
January 24, 2018 12:02
-
-
Save keehyun2/4a35ce0af48f245618b7f525abc84656 to your computer and use it in GitHub Desktop.
bubbleSort
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void bubbleSort(int[] arr){ | |
for(int i = arr.length - 1; i > 0; i --)// main loop, i 는 (배열의 길이 - 1) 에서 1까지 1씩 감소 | |
for(int j =0; j < i ; j++) // j 는 0부터 i 까지 1씩 증가하며 반복 | |
if(arr[j] > arr[j+1]) swap(arr, j, j+1); // index 가 작은 원소가 클경우 교환 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment