Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static int largeIndex(int[] myArr, int endIndex)
- {
- {
- int biggest = Integer.MIN_VALUE;
- for (int i=0; i <= endIndex; i++)
- {
- if(myArr[i] > biggest)
- biggest = i;
- }
- return biggest;
- }
- }
- private static int[] sortRecursive(int[] myArr, int endIndex)
- {
- int topIndex = largeIndex(myArr, endIndex);
- if(endIndex <= 0)
- {
- return myArr;
- }
- else
- {
- int temp = myArr[topIndex];
- myArr[topIndex] = myArr[endIndex];
- myArr[endIndex] = temp;
- sortRecursive(myArr, endIndex - 1);
- return myArr;
- }
- }
Add Comment
Please, Sign In to add comment