Question: 4. Given the below doubly-linked List, write a swap routine to swap the third and fifth values in the List (i.e. 'C' and 'E'). Your
4. Given the below doubly-linked List, write a swap routine to swap the third and fifth values in the List (i.e. 'C' and 'E'). Your swap routine does not need to be written as a method, but it must call advanceIterator, addIterator, getIterator, pointIterator, and removeIterator - and no other methods - or use any other structures (array, ArrayList, etc.) to perform the swap. Note that I give the example below for clarity. However, please write your swap code so that it will work with any List of Characters of sufficient length.
Listlist = new List<>(); list.addLast('A'); list.addLast('B'); list.addLast('C'); list.addLast('D'); list.addLast('E'); list.addLast('F'); list.addLast('G');
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
