Package com.zybooks.dsaj.recursion
Class ArrayReverse
java.lang.Object
com.zybooks.dsaj.recursion.ArrayReverse
Demonstration of recursive method for reversing an array's elements.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
reverseArray
(int[] data, int low, int high) Reverses the contents of subarray data[low] through data[high] inclusive.static void
reverseIterative
(int[] data) Reverses the contents of the given array.
-
Constructor Details
-
ArrayReverse
public ArrayReverse()
-
-
Method Details
-
reverseArray
public static void reverseArray(int[] data, int low, int high) Reverses the contents of subarray data[low] through data[high] inclusive.- Parameters:
data
- an array of integerslow
- the index of the first element in the range to be reversedhigh
- the index of the last element in the range to be reversed
-
reverseIterative
public static void reverseIterative(int[] data) Reverses the contents of the given array.- Parameters:
data
- an array of integers
-