Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

for java Q3: boolean isEmpty(); //return true if queue is empty, false otherwise int size(); //return the number of elements in the queue void enqueue(int

for java image text in transcribed
image text in transcribed
Q3: boolean isEmpty(); //return true if queue is empty, false otherwise int size(); //return the number of elements in the queue void enqueue(int e); //add a new node with element value e to the end of queue void enqueue(Node n); //add node n to the end of the queue Node dequeue(); //remove the node at the front of the queue and return it Node first(); //return the node at the front of the queue without removing it Node last(); //return the node at the rear of the queue without removing it Implement a linked list queue of the interface shown as explained in the lecture notes, you can copy it and make any necessary changes, if any. You need to a. Define a Node class that has an integer element and a reference to the next node. Provide a constructor that initialize the value of the element and set and get methods for the element and the next variables. b. Define a LinkedQueue class that stores a reference to the front node, a reference to the rear node, and size. Implement the methods shown in the interface. C. Add a method print: void print(). This method should print the value of the nodes of non-empty queue to the screen starting from front to the rear of the queue. d. Add a method findAt: int findAt(int p). This method should return the element of the node at position p of non-empty queue. Note, p also must be a valid position in 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

Recommended Textbook for

Successful Keyword Searching Initiating Research On Popular Topics Using Electronic Databases

Authors: Randall MacDonald, Susan MacDonald

1st Edition

0313306761, 978-0313306761

More Books

Students also viewed these Databases questions