Recall the IntegerList ADT whose interface is reproduced below. (Comments are in
ID: 3711367 • Letter: R
Question
Recall the IntegerList ADT whose interface is reproduced below. (Comments are included to remind you what each method does.) public interface Integerlistinterfacel public boolean isEmptyO: // return true iff list has no elements public int size O public int get (int index)7 return list element at index public void add (int index, int newItem): // insert newItem at index public void remove (int index) // delete element at index public void removeAll // reset list to empty state //retur umber of elements in list . Write a static void method called reverse2 with the following heading that reverses the order of the items in the list between indices start and end inclusive. Use only the ADT operations above and function swap from problem 1 to do this. Do this using recursion. public static void reverse2 (IntegerList list, int start, int end)(Explanation / Answer
static void swap(IntegerListInterface list, int i, int j) { int value = list.get(i); list.remove(i); list.add(i, list.get(j)); list.remove(j); list.add(j, value); } public static void reverse(IntegerListInterface list) { for(int i = 0; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.