Question: For this project, we will create a data structure known as a queue. A queue can be thought of as a line. Items are added

For this project, we will create a data structure known as a queue. A queue can be thought of as a line. Items are added at the end of the line and are taken from the front of the line. You will create a class LinkedQueue based on one of the linked-list classes given in this chapter. It should have private attributes for

  • front—a reference to the first node in the linked list of queue items
  • count—the number of items in the queue

and the following operations:

  • addToQueue(item)—adds item to the end of the queue. (Add it at the end of the linked list.)
  • removeFromQueue()—removes the first item from the queue and returns it. If the queue is empty, returns null.
  • isEmpty—returns true if the queue contains no items; otherwise, returns false.

Create a program that demonstrates the methods of the LinkedQueue class.

Step by Step Solution

3.55 Rating (172 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

public class LinkedQueue private ListNode front private int count public LinkedQueue front null count 0 Displays the data on the queue public void showQueue ListNode position front while position null ... View full answer

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 Java An Introduction to Problem Solving and Progra Questions!