Posts

Showing posts from June, 2016

Bubble Sort In Java

Image
Code : public class BubbleSort {     static int swapCount=0;     static int passes=0;             public static void main(String[] args) {         int[] array={5,1,4,2,8};                 printArray(array);//Before                 bubbleSort(array);                 printArray(array);//After                 System.out.println("\n Total Passes:"+passes);                 System.out.println("\n Total Swaps:"+swapCount);     }     private static void bubbleSort(int[] array) {         boolean swapped=false;   ...