Question: Q2. (bonus) Write a linked list queue class which has the following (1) a reference to the front node, (2) a reference to the rear

 Q2. (bonus) Write a linked list queue class which has the

Q2. (bonus) Write a linked list queue class which has the following (1) a reference to the front node, (2) a reference to the rear node, (3) and site, implement the following method: boolean Empty(); //return true queue is empty, false otherwise int size(): I/return the number of elements in the que void enqueueinte: //add a new node with element value to the end of queue int dequeuel). //remove the node at the front of the queue and return its element int first): /freturn the element of the node at the front of the queue without removing it int last07/return the element of the node at the rear of the queue without removing it printQueue. This method should take a queue and printits elements starting from front to the rear of the queue. (Only use queue operations) reversekueue. This method should take a queve and an integer then it should reverse the order of the fint integers in the queue leaving the rest unchanged. (Only use que operations, and any necessary data structurel (Hint: Use a stack to help you) For example Input 10, 20, 30, 40, 50, 60, 70, 80, 90, 1001 KES Output: 150,40,30, 20, 10,00 70., 80, 90, 1000 Add a test program that creates an empty queue and initialit. Then it should call printueue for the created queue. Then asks the user to enter an integer it should be valid, that is between 1 and site of the queue). Then, call reversekueue to reverse the first elements of the queue. Then call printueue to print the queue after the reverse operation Note: remember you can always reuse your codel You don't have to rewrite your linked ist class just use it to implement the queue:)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!