Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class BubbleSort {
- static void bubbleSort(int array []){
- int n = array.length ;
- int temp = 0;
- for(int i=0; i < n; i++){
- for(int j=1; j < (n-i); j++){
- if(array[j-1] > array[j]){
- //swap elements
- temp = array[j-1];
- array[j-1] = array[j];
- array[j] = temp;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement