Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. import java.util.*;
  2. public class BubbleSort {
  3.     static void bubbleSort(int array []){
  4.         int n = array.length ;
  5.         int temp = 0;  
  6.         for(int i=0; i < n; i++){  
  7.                 for(int j=1; j < (n-i); j++){  
  8.                          if(array[j-1] > array[j]){  
  9.                                 //swap elements  
  10.                                 temp = array[j-1];  
  11.                                 array[j-1] = array[j];  
  12.                                 array[j] = temp;  
  13.                         }  
  14.                          
  15.                 }  
  16.         }
  17.  
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement