Question: In this exercise, you will add a non - staticmethod swapNodes ( intnode 1 Index, intnode 2 Index ) toSinglyLinkedList class from week 2 lecture
In this exercise, you will add a nonstaticmethod swapNodesintnodeIndex, intnodeIndextoSinglyLinkedList class from week lecture examples. This method should swap the elements of two nodes where nodeIndexis the index of one node, and nodeIndexis the index of the other node. Here, we assume, the front node of the list is the first node, the node next to the first node is the second node, and so on Thus, the index implies firstnode, index implies the second node, and so on Write the main method to test the swapNodes method. Hint: You may need to traverse the list.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
