public static void bubbleSortImproved(int[] a){
		   System.out.println("Array before sorting");
		   for(int i:a)
		   System.out.print(i+" ");
		   System.out.println();
		   System.out.println("Sorting sequences after each iteration");
	       int n=a.length;
	       boolean swapped=true;
	       for(int i=0;i<n&&swapped;i++){
	    	   swapped=false;
	    	   for(int j=0;j<(n-i-1);j++){
	    		   if(a[j]>a[j+1]){
	    			   //swap elements, greatest one bubbles out.
	    			   int temp=a[j];
	    			   a[j]=a[j+1];
	    			   a[j+1]=temp;
	    			   swapped=true;
	    		   }
	    	   }
	    	   for(int k:a)
	        	   System.out.print(k+" ");
			   System.out.println();
	       }
	       System.out.println("Array after sorting");
	       for(int i:a)
	    	   System.out.print(i+" ");
		}