Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
(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
Step: 1
The method insertStudentIntoLastChair is used to insert a new student into the last chair of the cir...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started