Guest User

Untitled

a guest
Apr 21st, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 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; 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.  
  26. int temp = myArr[topIndex];
  27. myArr[topIndex] = myArr[endIndex];
  28. myArr[endIndex] = temp;
  29. sortRecursive(myArr, endIndex - 1);
  30. return myArr;
  31. }
  32. }
Add Comment
Please, Sign In to add comment