Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

5 Discuss what change circumstances have affected you and how.

Answered: 1 week ago

Question

Have roles been defined and assigned?

Answered: 1 week ago

Question

Are these written ground rules?

Answered: 1 week ago

Question

How do members envision the ideal team?

Answered: 1 week ago