Question: Consider the following singly linked list, where e indicates the type of the elements stored in the list. public class SLinkedList { private SNode head;

 Consider the following singly linked list, where e indicates the type
of the elements stored in the list. public class SLinkedList { private

Consider the following singly linked list, where e indicates the type of the elements stored in the list. public class SLinkedList { private SNode head; private class SNode { E element; SNode next; } } Assume inside the SLinked List class the following private method has been defined: private void swap (SNode nodel, SNode node2) { E temp node1.element; node1.element node 2.element; node2.element temp; Using the method above, fill in the missing expressions/statements below for a method that takes no inputs, traverses the list and swaps pairs of elements. For example, if the list had the following elements A B C D E F, then after the method has been executed, the list will contain the elements in the following order BADCF E. The method should work no matter the size of the list. Note that the method does not return anything, it just performs all the swaps. The time complexity for this method should be O(n), where n is the number of elements in the list (i.e. the number of basic steps to execute is proportional to the number of elements in the list). public void swapPairs() { SNode node = this.head; while ( ***BLANK1*** ) { ***BLANK2*** ***BLANK3*** > Blank # 1 Blank # 2 Blank # 3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!