link = null; } 10 11 12 130 14 public void setInfo(T info) { this.info = info; } 15 16 public T getInfo() { return info; } 170 18 19 20 public void setLink(LLNode link) { this. link = link; } 210 22 23 24 250 26 27 public LLNode getLink() { return link; }

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter18: Stacks And Queues
Section: Chapter Questions
Problem 16PE: The implementation of a queue in an array, as given in this chapter, uses the variable count to...
icon
Related questions
Question

how to create Circular Linked Queue without using a front reference that implements a queueinterface, also include a toString method that match the output: 

c

d

then write a driver program to test it?(note that front=rear.getLink())

the driver program should dequeue first element(use try catch) than enqueue a, enqueue b, dequeue, dequeue, enqueue c, enqueue d

screen shot show the queueinterface and LLnode

 

public class LLNode<T> {
protected LLNode<T> link;
protected T info;
5
7
public LLNode (T info) {
this.info = info;
link = null;
}
80
9
10
11
12
public void setInfo(T info) {
this.info = info;
}
130
14
15
16
public T getInfo() {
return info;
}
170
18
19
20
210
22
public void setLink(LLNode<T> link) {
this.link = link;
}
23
24
250
public LLNode<T> getLink() {
return link;
}
26
27
28 }
Transcribed Image Text:public class LLNode<T> { protected LLNode<T> link; protected T info; 5 7 public LLNode (T info) { this.info = info; link = null; } 80 9 10 11 12 public void setInfo(T info) { this.info = info; } 130 14 15 16 public T getInfo() { return info; } 170 18 19 20 210 22 public void setLink(LLNode<T> link) { this.link = link; } 23 24 250 public LLNode<T> getLink() { return link; } 26 27 28 }
public interface QueueInterface<T> {
void enqueue(T element) throws Queue0verflowException;
// Throws QueueOverflowException if this queue is full;
// otherwise, adds element to the rear of this queue.
T dequeue () throws QueueUnderflowException;
// Throws QueueUnderflowException if this queue is empty;
// otherwise, removes front element from this queue and returns it.
boolean isFull();
// Returns true if this queue is full; otherwise, returns false.
boolean isEmpty();
// Returns true if this queue is empty; otherwise, returns false.
int size();
// Returns the number of elements in this queue.
}
Transcribed Image Text:public interface QueueInterface<T> { void enqueue(T element) throws Queue0verflowException; // Throws QueueOverflowException if this queue is full; // otherwise, adds element to the rear of this queue. T dequeue () throws QueueUnderflowException; // Throws QueueUnderflowException if this queue is empty; // otherwise, removes front element from this queue and returns it. boolean isFull(); // Returns true if this queue is full; otherwise, returns false. boolean isEmpty(); // Returns true if this queue is empty; otherwise, returns false. int size(); // Returns the number of elements in this queue. }
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Threads in linked list
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning