Java: An Introduction to Problem Solving and Programming (8th Edition)
8th Edition
ISBN: 9780134462035
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 12, Problem 12PP
Program Plan Intro
Implementation of queue using circular linked list
Program Plan:
Filename: “CircularLinkedQueue.java”
- Define “CircularLinkedQueue” class.
- Declare variable for reference of first node, rear node and number of items.
- Default constructor for “CircularLinkedQueue” class.
- Set front and rear to “null” and count to “0”.
- Define the method “addToQueue()” with argument of “item”.
- If “front” is not equal to “null”, then
- Create a new node using “QueueNode” class.
- Set the new node as next to rear.
- Set the new node as rear.
- Set the new node at last.
- If the queue is empty, then
-
- Assign the next node to “null” by using “QueueNode” class.
- Set rear to front for single node in queue.
- Make the front as next to rear
- Increment the number of items.
- If “front” is not equal to “null”, then
- Define the method “removeFromQueue()”.
- If the queue is not empty, then get the element at front node by calling “getQueueElement()” method and eliminate the front node.
- Update the front and decrement the number of items.
- Finally returns the resultant element.
- If the queue is empty, then returns null.
- If the queue is not empty, then get the element at front node by calling “getQueueElement()” method and eliminate the front node.
- Define the method “isEmpty()”.
- This method returns “true” if the value of “count” is equal to “0”. Otherwise, returns “false”.
- Define the method “displayQueueValues()”.
- Declare a variable for node position.
- Create a reference to front.
- Performs “while” loop. This loop will repeat to display all elements in queue.
- Display the element of the queue.
- Go to the next node by using “getNextNode()” method.
Filename: “QueueNode.java”
- Define “QueueNode” class.
- Declare required variables for queue elements and next node value.
- Create default constructor for “QueueNode” class.
- Assign “null” values for queue elements and next node.
- Create the parametrized constructor for “QueueNode” class.
- Define the method “setNextNode()” which is used to set value for next node.
- Define the method “getNextNode()” which is used to returns the next node value.
- Define the method “setQueueElement()” which is used to assign value for queue elements.
- Define the method “getQueueElement()” which is used to returns queue elements.
Filename: “CircularLinkedQueueTest.java”
- Define “CircularLinkedQueueTest” class.
- Define main function.
- Create an object “nameQueue” for “CircularLinkedQueueTest” class.
- Add names to object “nameQueue” by using “addToQueue()” method.
- Call the method “displayQueueValues()” to display the elements in queue.
- Remove an element from the queue by calling the method “removeFromQueue()”.
- Display the result of whether the queue is empty or not by calling the method “isEmpty()”.
- Display the elements in queue after removing an element from queue by calling the method “displayQueueValues()”.
- Remove the elements from the queue by calling the method “removeFromQueue()”.
- Display the result of whether the queue is empty or not by calling the method “isEmpty()”.
- Define main function.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
(Short-answer) b. Continue from the previous question. Suppose part of the data you extracted from the data warehouse is the following. Identify the missing values you think exist in the dataset. Use Column letter and Row number to refer to each missing value in the dataset. Please write down how you want to address each particular missing value (you can group them if they receive same treatment). For imputation, you do not need to calculate the exact imputed values but just describe what kind of value you want to use to impute.
Please original work
Locate data warehousing solutions offered by IBM, Oracle, Microsoft, and Amazon
Compare and contrast the capabilities of each solution and provide several names of some organizations that utilize each of these solutions.
Please cite in text references and add weblinks
Need Help: Which of the following statements about confusion matrix is wrong
A) Confusion matrix is a performance measure for probability prediction techniques
B) Confusion matrix is derived based on classification rules with cut-off value 0.5
C) Confusion matrix is derived based on training partition to measure a model’s predictive performance
D) None of the above
Chapter 12 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Ch. 12.1 - Suppose aList is an object of the class...Ch. 12.1 - Prob. 2STQCh. 12.1 - Prob. 3STQCh. 12.1 - Prob. 4STQCh. 12.1 - Can you use the method add to insert an element at...Ch. 12.1 - Prob. 6STQCh. 12.1 - Prob. 7STQCh. 12.1 - If you create a list using the statement...Ch. 12.1 - Prob. 9STQCh. 12.1 - Prob. 11STQ
Ch. 12.1 - Prob. 12STQCh. 12.2 - Prob. 13STQCh. 12.2 - Prob. 14STQCh. 12.2 - Prob. 15STQCh. 12.2 - Prob. 16STQCh. 12.3 - Prob. 17STQCh. 12.3 - Prob. 18STQCh. 12.3 - Prob. 19STQCh. 12.3 - Write a definition of a method isEmpty for the...Ch. 12.3 - Prob. 21STQCh. 12.3 - Prob. 22STQCh. 12.3 - Prob. 23STQCh. 12.3 - Prob. 24STQCh. 12.3 - Redefine the method getDataAtCurrent in...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.4 - Revise the definition of the class ListNode in...Ch. 12.4 - Prob. 30STQCh. 12.5 - What is the purpose of the FXML file?Ch. 12.5 - Prob. 32STQCh. 12 - Repeat Exercise 2 in Chapter 7, but use an...Ch. 12 - Prob. 2ECh. 12 - Prob. 3ECh. 12 - Repeat Exercises 6 and 7 in Chapter 7, but use an...Ch. 12 - Write a static method removeDuplicates...Ch. 12 - Write a static method...Ch. 12 - Write a program that will read sentences from a...Ch. 12 - Repeat Exercise 12 in Chapter 7, but use an...Ch. 12 - Write a program that will read a text file that...Ch. 12 - Revise the class StringLinkedList in Listing 12.5...Ch. 12 - Prob. 12ECh. 12 - Write some code that will use an iterator to...Ch. 12 - Prob. 14ECh. 12 - Write some code that will use an iterator to...Ch. 12 - Prob. 17ECh. 12 - Revise the method selectionSort within the class...Ch. 12 - Repeat the previous practice program, but instead...Ch. 12 - Repeat Practice Program 1, but instead write a...Ch. 12 - Write a program that allows the user to enter an...Ch. 12 - Write a program that uses a HashMap to compute a...Ch. 12 - Write a program that creates Pet objects from data...Ch. 12 - Repeat the previous programming project, but sort...Ch. 12 - Repeat the previous programming project, but read...Ch. 12 - Prob. 9PPCh. 12 - Prob. 10PPCh. 12 - Prob. 11PPCh. 12 - Prob. 12PPCh. 12 - Prob. 13PPCh. 12 - Prob. 14PPCh. 12 - Prob. 15PP
Knowledge Booster
Similar questions
- I have a few questions I need help with Statement: When we build a nearest neighbor model, we shall not remove the redundant dummies when coding a categorical variable. True or False Statement: One reason why a neural network model often requires a significant number of data observations to train is that it often has a significant number of model parameters to estimate even if there are only a few predictors. True or False. Which of the following statements about confusion matrix is wrong A) Confusion matrix is a performance measure for probability prediction techniques B) Confusion matrix is derived based on classification rules with cut-off value 0.5 C) Confusion matrix is derived based on training partition to measure a model’s predictive performance D) None of the abovearrow_forwardStudent ID is 24241357arrow_forwardWhich of the following methods help when a model suffers from high variance? a. Increase training data. b. Increase model size. c. Decrease the amount of regularization. d. Perform feature selection.arrow_forward
- 57 Formula 1 point Use shift folding, length 3, on the following value to calculate the Hash Value. 114184121 Type your answer...arrow_forwardWrite a program that reads a list of 10 integers, and outputs those integers in reverse. For coding simplicity, follow each output integer by a space, including the last one. Then, output a newline. Ex: If the input is: 2 4 6 8 10 12 14 16 18 20 the output is: 20 18 16 14 12 10 8 642 To achieve the above result, first read the integers into an array. Then output the array in reverse. 623802 1031906 nx3zmv7.arrow_forward6.3B-2. Multiple Access protocols (2). Consider the figure below, which shows the arrival of 6 messages for transmission at different multiple access nodes at times t=0.1, 0.8, 1.35, 2.6, 3.9, 4.2. Each transmission requires exactly one time unit. 1 2 3 4 t=0.0 t=1.0 t=2.0 t=3.0 5 6 t=4.0 t=5.0 For the slotted ALOHA protocol, indicate which packets are successfully transmitted. You can assume that if a packet experiences a collision, a node will not attempt a retransmission of that packet until sometime after t=5. 1 2 3 4 5 Karrow_forward
- Problem of checking Compile errors Runtime errors ======== } ng; } You have the following IQueue interface. Implement a Queue class derived from IQueue. You can use STL containers discussed in class, such as vector, queue, stack, deque, map. #include using namespace std; class IQueue { public: }; virtual void Enqueue(int val) virtual int Dequeue() = 0; virtual int Size() const = 0; int main() = 0; { Queue q; ===== } cout << q.Size() << endl; q. Enqueue(10); q.Enqueue(20); q. Enqueue(30); cout << q.Size() << endl; cout << q.Dequeue() << endl; cout << q.Size() << endl; cout << q.Dequeue() << endl; cout << q.Size() << endl; cout << q.Dequeue() << endl; cout << q.Size() << endl; ==== ====arrow_forwardlogicarrow_forwardQ1: For the Figure Below if the input to the first tank is step with magnitude 2 find 1. What type of relation between (tanks 1 and 2) and tank 3 2. Initial real value of H2, if the steady state value is 10 3. Final Value of H3 4. H1 at t=1.5 5. For the system tank1 and tank 2 only which case is applied to them (overdamping, underdamped or critically damping) A₁=1 A₂=1 Tank 1 R₁ = 2 * Tank 2 R₁₂=2 A3=0.5 hy R₁=4 Tank 3arrow_forward
- Please original work Talk about the most common challenges encountered in a data warehouse What are some creative ways to overcome those challenges What is for one real world example where your method would be effective Please cite in text references and add weblinksarrow_forwardWhat is the differences between mobile website navigation and traditional website navigation?arrow_forwardPoint 10:26 Explain P 10:26 10:25arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education