Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void bBSort(int[] arr) //int[] arr = {64, 34, 25, 12, 22, 11, 90};
- {
- int n = arr.length;
- for(int i=0;i<n-1;i++) // 0
- {
- for(int j = 0; j<n-i-1; j++) //0 1 2 3 4 5 6| 0 1 2 3 4 5| 0 1 2 3 4| 0 1 2 3 | 0 1 2| 0 1|
- {
- if(arr[j]>arr[j+1]) /// 64 > 34 | 64>25
- {
- int temp = arr[j]; // temp = 64 | temp = 64
- arr[j] = arr[j+1]; // arr[0] = 34 | arr[1] = 25
- arr[j+1] = temp; // arr[1] = 64 | arr[2] = 64
- } //34,64,25,12,22,11,90 | 34,25,64,12,22,11,90 // sort
- }
- }
- }
- //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement