Since this is your homework, I offer an example:
This sequence: 1 2 3 4 5 6 7 8 9 10
You can change to: 10 2 3 4 5 6 7 8 9 1
After that: 10 9 3 4 5 6 7 8 2 1
.....
As you can see, step by step, the sequence is "better" and the problem is "less." So the problem you have to solve is this:
1) How to apply a recursive call for this method. for the original method: reverse(int[] a) . therefore, after the first step, you should create an array b from a[2] --> a[n-1] . and using reverse (int [] b) `.
2) after reverse b , what should we do to reverse? Assign b values ββto again for.
3) stop condition: what is the stop condition? You see that the elements of array b are smaller than the elements of array a. So what step should we stop?
Hope this help :)
hqt Oct 31 '12 at 2:15 2012-10-31 02:15
source share