0

An example of bubble sorting in arrats in java

plz give a complete program of bubble sorting in array. I want to understand it deeply by an example.

2nd Oct 2017, 2:49 PM
Ashish Upadhyay
Ashish Upadhyay - avatar
1 ответ
+ 10
int[] arr = {2, 3, 4, 1, 5}; for (int i = 0; i < arr.length; i++) for (int j = 0; j < arr.length - 1 - i; j++) if (arr[j] > arr[j + 1]) { int temp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = temp; } for (int i : arr) System.out.println(i);
2nd Oct 2017, 3:22 PM
Hatsy Rei
Hatsy Rei - avatar