Guest User

Untitled

a guest
Apr 21st, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1.  private static int largeIndex(int[] myArr, int endIndex)
  2.     {
  3.        {
  4.            int biggest = Integer.MIN_VALUE;
  5.            for (int i=0; i < endIndex+1; i++)
  6.            {
  7.                if(myArr[i] > biggest)
  8.                biggest = i;
  9.            }
  10.            return biggest;
  11.         }
  12.     }
  13.    
  14.    
  15.     private static int[] sortRecursive(int[] myArr, int endIndex)
  16.     {
  17.         int topIndex = largeIndex(myArr, endIndex);
  18.        
  19.         if(endIndex < 0)
  20.         {
  21.             return myArr;
  22.         }
  23.         else
  24.         {
  25.             int temp = myArr[topIndex];
  26.             myArr[topIndex] = myArr[endIndex];
  27.             myArr[endIndex] = temp;
  28.             sortRecursive(myArr, endIndex - 1);
  29.             return myArr;
  30.         }
  31.     }
Add Comment
Please, Sign In to add comment