Question: I need help with the implementation of the method insertStudentsIntoLastChair. The method is already answered. I just need help with an explanation of to why
I need help with the implementation of the method insertStudentsIntoLastChair. The method is already answered. I just need help with an explanation of to why and how to get that answer. 
(c) On the RUKindergarten assignment there are two linked lists of SNode: studentsInLine: a singly linked list musical Chairs: a circular linked list public class SNode { public Student student; // the data part of the node public SNode next; // a link to the next student int the linked list public SNode (Student s, SNode n) { students; next = n; } } For this question assume that Classroom contains the following methods. public class Classroom { private SNode students InLine; // reference to the FIRST student in the LL private SNode musicalChairs; // reference to the LAST student in the CLL // Removes and returns the first student in students InLine public Student removeFirstStudentFromLine () {} // inserts the argument Student as the last student in musicalChairs public void insertStudent Into LastChair (Student s) {} public void moveStudents FromLine IntoChairs () { while (students InLine != null) { Students = removeFirst Student FromLine(); insertStudent Into LastChair(s); Implement the method insertStudents Into LastChair, the method can be used in other methods besides moveStudents FromLineIntoChairs. public void insertStudent Into LastChair (Students) { SNode oldLast = musicalChairs; SNode musicalChairs = SNode (s, null); if (oldLast = null) { // list is empty musicalChairs.next = musicalChairs; } else { musicalChairs.next = old Last.next: oldLast.next = musicalChairs; } }
Step by Step Solution
There are 3 Steps involved in it
The method insertStudentIntoLastChair is used to insert a new student into the last chair of the cir... View full answer
Get step-by-step solutions from verified subject matter experts
