diff --git a/Assignment10/bin/RecursiveExercise.class b/Assignment10/bin/RecursiveExercise.class index f1c3ad2..cbdeec5 100644 Binary files a/Assignment10/bin/RecursiveExercise.class and b/Assignment10/bin/RecursiveExercise.class differ diff --git a/Assignment10/src/RecursiveExercise.java b/Assignment10/src/RecursiveExercise.java index af58b2c..1b5e706 100644 --- a/Assignment10/src/RecursiveExercise.java +++ b/Assignment10/src/RecursiveExercise.java @@ -20,18 +20,9 @@ public class RecursiveExercise { return null; if (ht.length == 1) return ht.clone(); - return append(new int[] { ht[ht.length - 1] }, append( - reverse(MyArrayUtil.tail(removeLast(ht.clone(), new int[ht.length - 1], 0))), new int[] { ht[0] })); + return append(reverse(MyArrayUtil.tail(ht)),new int[] {MyArrayUtil.head(ht)}); } - // Remove the last element - - public static int[] removeLast(int[] ia1, int[] ia2, int i) { - ia2[i] = ia1[i]; - if (i == ia2.length - 1) - return ia2; - return removeLast(ia1, ia2, i + 1); - } public static boolean isIn(int x, int[] a) throws Exception { // fill your code here