9.2 Rewrite the SLList implementation and call the new implementation CircularQueue. You will be deleting a...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
9.2 Rewrite the SLList implementation and call the new implementation CircularQueue. You will be deleting a lot of methods from SLList because the CircularQueue API is much smaller in comparison: the entire CircularQueue API has four methods described in Table 9.3. Your CircularQueue implementation must meet the following specifications: 1 2 3 4 5 6 7 8 9 Your CircularQueue implementation will use a circular linked list, which is the same as a linked list except that no links are null (that is, no node's next field is ever null) and the value of last.next is first whenever the list is not empty. CircularQueue keeps only one Node instance variable last. > CircularQueue has a private inner class called Node, just like SLList, except that CircularQueue's Node is simpler and is exactly the same as what's shown on lines 5 - 8 below: public class CircularQueue { private Node last; // references the most recently added Node private int n; // number of Nodes in this CircularQueue private class Node { E data; Node next; } 10 11 | // Other methods follow (With this Node class, your addLast and removeFirst methods will have to do the work that was previously done by the Node constructor in SLList. Also note that you will be renaming addLast to enqueue and removeFirst to dequeue.) > All of CircularQueue's public methods are shown in Table 9.3. void E } Table 9.3 CircularQueue API int Method enqueue (E element) dequeue () boolean isEmpty() size() What it does Inserts element as the last element of the Queue Removes and returns the first element of the Queue (the element that has been in the Queue the longest) Returns true if the Queue is empty and false if it isn't Returns the number of items in the list 9.2 Rewrite the SLList implementation and call the new implementation CircularQueue. You will be deleting a lot of methods from SLList because the CircularQueue API is much smaller in comparison: the entire CircularQueue API has four methods described in Table 9.3. Your CircularQueue implementation must meet the following specifications: 1 2 3 4 5 6 7 8 9 Your CircularQueue implementation will use a circular linked list, which is the same as a linked list except that no links are null (that is, no node's next field is ever null) and the value of last.next is first whenever the list is not empty. CircularQueue keeps only one Node instance variable last. > CircularQueue has a private inner class called Node, just like SLList, except that CircularQueue's Node is simpler and is exactly the same as what's shown on lines 5 - 8 below: public class CircularQueue { private Node last; // references the most recently added Node private int n; // number of Nodes in this CircularQueue private class Node { E data; Node next; } 9.2 Rewrite the SLList implementation and call the new implementation CircularQueue. You will be deleting a lot of methods from SLList because the CircularQueue API is much smaller in comparison: the entire CircularQueue API has four methods described in Table 9.3. Your CircularQueue implementation must meet the following specifications: 1 2 3 4 5 6 7 8 9 Your CircularQueue implementation will use a circular linked list, which is the same as a linked list except that no links are null (that is, no node's next field is ever null) and the value of last.next is first whenever the list is not empty. CircularQueue keeps only one Node instance variable last. > CircularQueue has a private inner class called Node, just like SLList, except that CircularQueue's Node is simpler and is exactly the same as what's shown on lines 5 - 8 below: public class CircularQueue { private Node last; // references the most recently added Node private int n; // number of Nodes in this CircularQueue private class Node { E data; Node next; } 10 11 | // Other methods follow (With this Node class, your addLast and removeFirst methods will have to do the work that was previously done by the Node constructor in SLList. Also note that you will be renaming addLast to enqueue and removeFirst to dequeue.) > All of CircularQueue's public methods are shown in Table 9.3. void E } Table 9.3 CircularQueue API int Method enqueue (E element) dequeue () boolean isEmpty() size() What it does Inserts element as the last element of the Queue Removes and returns the first element of the Queue (the element that has been in the Queue the longest) Returns true if the Queue is empty and false if it isn't Returns the number of items in the list 10 11 | // Other methods follow (With this Node class, your addLast and removeFirst methods will have to do the work that was previously done by the Node constructor in SLList. Also note that you will be renaming addLast to enqueue and removeFirst to dequeue.) > All of CircularQueue's public methods are shown in Table 9.3. void E } Table 9.3 CircularQueue API int Method enqueue (E element) dequeue () boolean isEmpty() size() What it does Inserts element as the last element of the Queue Removes and returns the first element of the Queue (the element that has been in the Queue the longest) Returns true if the Queue is empty and false if it isn't Returns the number of items in the list
Expert Answer:
Related Book For
Statistics Unlocking The Power Of Data
ISBN: 9780470601877
1st Edition
Authors: Robin H. Lock, Patti Frazer Lock, Kari Lock Morgan, Eric F. Lock, Dennis F. Lock
Posted Date:
Students also viewed these programming questions
-
answer all questions as instructed below. attend all questions. 4 Computer Vision (a) Explain why such a tiny number of 2D Gabor wavelets as shown in this sequence are so efficient at representing...
-
"Fortran, Algol and Lisp invented most programming language concepts 50 years ago; adding the concept of object-orientation suffices to explain all programming languages to date". To what extent is...
-
Guidance Residential in Reston, Virginia, offers a Shari'ah-compliant housing finance product for Muslims and others who do not believe in collecting or paying interest. Under their Declining Balance...
-
Tandy Company was issued a charter by the state of Indiana on January 15 of this year. The charter authorized the following: Common stock, $10 par value, 103,000 shares authorized Preferred stock, 9...
-
14. The Centipede Company uses standard costing. The following data are available for October: Actual quantity of direct materials used 23,500 pounds Standard price of direct materials P 2 per pound...
-
Wayne Robichaud, Attorney, P.C., began the year with total assets of \($127,000\), liabilities of \($78,000\), and stockholders equity of \($49,000\). During the year the business earned rev enue of...
-
Applying the net present value approach with and without tax considerations Luther Currie, the president of Luther's Moving Services, Inc., is planning to spend $625,000 for new trucks. He expects...
-
why is finacing one of the most difficult aspect in managing export import transactions
-
Part One: In 2015, Fran Lexa opened Fran's Flowers, a small shop selling floral arrangements. On December 31, 2016, her accounting records show the following: Sales revenue...
-
A B C D E F 9 10 1234567822222222222 19 20 11 You learned about Income Statements this week. Fill in the missing items below. Enter the answers in blue shaded cells Sales COGS Gross profit G&A...
-
Consider the chemical reaction: aPbNe+bCrMnOscCrO3 +dMnO + ePbO4 + NO (a) Write out a system of equations that can be used to balance the reaction. (b) Find the general solution to the system from...
-
You are the new Rooms / F&B Division Director ( chose 1 ) of a prestigious XX star luxury hotel in Barcelona named " La Pasin ". You have been hired a week ago to fill the position and within your...
-
What is the role of leadership in driving organizational effectiveness, and what leadership styles tend to foster a culture of high performance and continuous improvement ?
-
What is the mass of a suitcase in pounds if it weighs 19.5 kilograms? (1 kg = 2.205 lb) Use the correct number of significant figures and do not put in scientific notation. D Question 5 1 pts If a...
-
Part A A 6.00 A current runs through a 12 gauge copper wire (diameter 2.05 mm) and through a light bulb. Copper has 8.5 x 1028 free electrons per cubic meter. How many electrons pass through the...
-
2. Consider this string: "MUALLA KOKULU MUMU ALMA". Answer the following assuming that "space" character is not part of your string. a. Design a Shannon-Fano code to code these source symbols. (Your...
-
Economic feasibility is an important guideline in designing cost accounting systems. Do you agree? Explain.
-
Determine whether it is appropriate to use the normal distribution to estimate the p-value. If it is appropriate, use the normal distribution and the given sample results to complete the test of the...
-
The study on genetics and fast-twitch muscles includes a sample of elite sprinters, a sample of elite endurance athletes, and a control group of nonathletes. Is there an association between genetic...
-
In elementary school (grades 1 to 6), there is a strong association between a childs height and the childs reading ability. Taller children tend to be able to read at a higher level. However, there...
-
How does IT enable business process engineering?
-
What impact is the SMAC model having on business?
-
Is on-demand work a viable option for you? Explain.
Study smarter with the SolutionInn App