I need help with the implementation of the method insertStudentsIntoLastChair. The method is already answered. I just
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
(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; } } (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; } }
Expert Answer:
Answer rating: 100% (QA)
The method insertStudentIntoLastChair is used to insert a new student into the last chair of the cir... View the full answer
Related Book For
Management Accounting
ISBN: 9780730369387
4th Edition
Authors: Leslie G. Eldenburg, Albie Brooks, Judy Oliver, Gillian Vesty, Rodney Dormer, Vijaya Murthy, Nick Pawsey
Posted Date:
Students also viewed these programming questions
-
In Strategy Spotlight 8.1, we saw how TJ Parker took something that bugged him and turned it into a very valuable business. Consider something that bugs or has bugged you and develop a business idea...
-
(a) Explain how a limit worth may be tended to at run-time, both in a syntaxtree middle person and in collected code. What is the importance word "settled" already? [3 marks] (b) Give a model program...
-
Data set Theory Assume an informational record with one association parent including matches (a, b) where a can't try not to be a parent of b. (a) Write a Datalog demand which gives the graph of...
-
Della Simpson Inc. sells two popular brands of cookies, Dellas Delight and Bonnys Bourbon. Dellas Delight goes through the Mixing and Baking Departments and Bonnys Bourbon, a filled cookie, goes...
-
A particular form of cinnabar (HgS) adopts the zinc blende structure, Figure 12.26. The length of the unit cell edge is 5.852 . (a) Calculate the density of HgS in this form. (b) The mineral...
-
Edwards Deming, a pioneer in the area of statistical quality control, stated, "The cost of poor quality is unknown and unknowable." The quality categories-internal failure, external failure,...
-
The following information is available for Abdul Saleem, Inc., as of May 31, 20xx: a. Cash on the books as of May 31 amounted to $42,754.16. Cash on the bank statement for the same date was...
-
Consider the following time series data Using the nave method (most recent value) as the forecast for the next week, compute the following measures of forecast accuracy: a. Mean absolute error b....
-
6. [-/1 Points] DETAILS LARLINALG8 2.2.045. Find A A and AAT. A = [22 1] (a) ATA (b) AAT Which of the products are symmetric? (Select all that apply.) DATA O AAT Need Help? Read It Watch It
-
Are there any circumstances under which a country might want to increase its currencys value?
-
= For the purpose of this question you can assume NO population growth NOR technology growth (namely, you should solve the question with n = 0 and x = 0). Assume that Lo 1 and A0 = 1. Consider a...
-
Montgomery Industries spent $ 6 5 0 , 0 0 0 in 2 0 2 3 on a construction project to build a library. Montgomery also capitalized $ 3 2 , 5 0 0 of interest on the project in 2 0 2 3 . Montgomery...
-
Suppose a deposit intermediary receives $1,000,000 in savings deposits. Of these deposited funds, $200,000 is invested in short-term government securities and $800,000 is used to make 25-year...
-
need to be C++ for an academic integrity violation. Prerequisite Knowledge Although many teachers use total points to calculate student grades for a course, some use weighted categories. It is...
-
On January 1 , Five Star Services has the following balances: Accounts Receivable $ 2 5 , 0 0 0 ( debit ) Bad Debts Expense $ 0 Five Star Services has the following transactions during January:...
-
list the actions our government or another country took to stop COVID-19 and improve the economy. Did these actions work or not and why? Talk about how these programs have affected our budget or...
-
Homework: Week One Question 3, BE8-17 (simi.. HW Score: 9.09%, 1 of 11 points Part 1 of 2 Score: 0 of 1 Save Choco Cabin Construction Company uses the percentage-of-completion method, with the...
-
Consider the sections of two circuits illustrated above. Select True or False for all statements.After connecting a and b to a battery, the voltage across R1 always equals the voltage across R2.Rcd...
-
Using the data in Your Turn 13.5, how much water would be saved in a month if one-third of a town's population of 15,000 turned the faucet off when brushing their teeth except when rinsing?
-
Using the data in Example 13.5, how much water would be saved in a year if one-sixth of the population of the state of Florida, which is approximately 21.6 million people, turned the faucet off when...
-
Hurd Inc. prepays rent every three months on March 1, June 1, September 1, and December 1. Rent for the three months totals \(\$ 3,600\). On December 31, 2018, Hurd will report Prepaid Rent of: a....
Study smarter with the SolutionInn App