Advertisement
Guest User

Untitled

a guest
Mar 4th, 2016
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. static void  sortHelper(int[] array, int i)
  2.     {  
  3.         if (i<=0) {
  4.             System.out.println ( 0 );
  5.         }
  6.         int size = array.length;
  7.         if (!Ordered(array, i)){
  8.             int j = findMax(array, 0, i);
  9.             int flipPosition;
  10.  
  11.             if( j != i )
  12.             {
  13.                 if( j != 0 ) {
  14.                     flip( array, 0, j );
  15.                     flipPosition = size-j;
  16.                     System.out.print( flipPosition + " " );
  17.                 }
  18.  
  19.                 flip( array, 0, i );
  20.                 flipPosition = size-i;
  21.                 System.out.print( flipPosition + " " );
  22.             }
  23.         }
  24.  
  25.         sortHelper(array, i-1);
  26.     }
  27.    
  28.     public static void sort (int []array){
  29.         sortHelper(array, array.length-1);
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement