SlideShare a Scribd company logo
A generic queue is a general queue storage that can store an unlimited number of objects.
In this lab, you need to implement two types of the generic queue including Queue and Deque.
The Java code of this module includes a class that represent Queues and was mentioned briefly
during the lecture, therefore if you need to, please revisit the java code.
The second special type of containers is called a Deque. A deque is a special type of queue that is
double ended. It means that elements can be added to the queue at both ends and removing can
be from both ends. In essence, a deque follows both a FIFO (First in, First out) and a LIFO (Last
In, First Out) rules to insert/remove from/to the queue. This means that a deque can play the role
of a queue and a stack at the same time. You can imagine a stack as a plate dispenser. When you
add a plate, you add it to the top of the dispenser. When you remove a plate, you remove it from
the top again. However, for a queue, you can imagine a queue of students waiting in line. The first
student who comes into the line is the first student served and hence removed from the line.
For the stack behavior of a deque, there are two main and two auxiliary methods:
push(object): This method adds the object to the stack. IN other words, the object is added at the
front.
pop(): removes the last element that was added, from the stack. In other words, the object is
removed from the front.
top(): returns the element, which is at the top of the stack, without removing it.
getSize(): returns the number of elements in the stack.
Your job for this lab, is to complete GenericQueue, Queue and Deque class. I have written a
comment, where you need to insert your code.
3.1. Class GenericQueue
The names of the methods in this class explain themselves. If you need more clarification, please
read the javaDoc for these methods.
3.2. Class Queue
While Queue Is-A generic queue, it follows the rule of Queue data structure (FIFO), therefore all
the methods should be implemented in a way that the rule is followed.
This class has an instance variable that holds all the items. The rest of the methods are self-
explanatory.
3.3. Class Deque
The Deque class is a special type of a Queue that was explained above. So the deque acts as a
queue and has additional methods that represent the stack behaviour.
This class has a constructor that uses the list that contains the data. To implement the rest of the
methods see their javaDoc.
import java.util.*;
import java.io.*;
/**
* This class is a GenericQueue that holds an unlimited number of
* objects. It is able to remove objects and add objects.
*/
public class GenericQueue {
// No instance variable should be defined for this class.
/**
* This method adds the <code> obj </code> to the GenericQueue.
* @param obj is the object that is added to the GenericQueue.
*/
void add(Object object) {
// insert your code here
}
/**
* This method removes the object from the GenericQueue
* @return returns the removed object.
*/
Object remove() {
// insert your code here. You may want to change the return value.
return null;
}
/**
* @return It returns the number of elements in the GenericQueue.
*/
int getSize() {
// insert your code here. You may need to change the return value.
return 0;
}
}
/**
*
* This class simulates a Queue, which is a data structure that insert and remove data
* by FIFO (first-in, first-out) rule
*
*/
class Queue extends GenericQueue{
ArrayList<Object> queue;
/**
* This is the constructor that initializes the <code> queue </code>
*/
public Queue() {
}
/**
* This method adds the object into the Queue.
* Please note that the rule of the queue insertion/removal is
* First in, First out.
* @param obj is the object that is added to the queue.
*/
@Override
public void add(Object obj) {
}
/**
* This method removes an object from the Queue.
* Please note that the rule of the queue insertion/removal is
* First in, First out.
*/
@Override
public Object remove() {
return null;
}
/**
* @return returns the object which is in front of the queue.
*/
public Object top() {
return null;
}
/**
* Returns the number of items in the queue.
*/
@Override
public int getSize(){
return 0;
}
}
/**
*
* This class simulates a Deque, which is a data structure that insert and remove data
* by FILO (first-in, last-out) rule
*
*/
class Deque extends Queue{
/**
* This is the constructor that initializes the <code> deque </code>
*/
public Deque() {
}
/**
* This method adds an object to the deque treated as a stack.
* Please note that the rule of the deque insertion/removal is
* both First in, first out (FIFO), as well as Last in, First out (LIFO)
*/
public void push(Object obj) {
}
/**
* This method removes an object from the deque treated as a stack.
* Please note that the rule of the deque insertion/removal is
* both First in, first out (FIFO), as well as Last in, First out (LIFO)
*/
public Object pop() {
return null;
}
}
import java.util.*;
import java.io.*;
/**
* This class is a GenericQueue that holds an unlimited number of
* objects. It is able to remove objects and add objects.
*/
public class GenericQueue {
// No instance variable should be defined for this class.
/**
* This method adds the <code> obj </code> to the GenericQueue.
* @param obj is the object that is added to the GenericQueue.
*/
void add(Object object) {
// insert your code here
}
/**
* This method removes the object from the GenericQueue
* @return returns the removed object.
*/
Object remove() {
// insert your code here. You may want to change the return value.
return null;
}
/**
* @return It returns the number of elements in the GenericQueue.
*/
int getSize() {
// insert your code here. You may need to change the return value.
return 0;
}
}
/**
*
* This class simulates a Queue, which is a data structure that insert and remove data
* by FIFO (first-in, first-out) rule
*
*/
class Queue extends GenericQueue{
ArrayList<Object> queue;
/**
* This is the constructor that initializes the <code> queue </code>
*/
public Queue() {
}
/**
* This method adds the object into the Queue.
* Please note that the rule of the queue insertion/removal is
* First in, First out.
* @param obj is the object that is added to the queue.
*/
@Override
public void add(Object obj) {
}
/**
* This method removes an object from the Queue.
* Please note that the rule of the queue insertion/removal is
* First in, First out.
*/
@Override
public Object remove() {
return null;
}
/**
* @return returns the object which is in front of the queue.
*/
public Object top() {
return null;
}
/**
* Returns the number of items in the queue.
*/
@Override
public int getSize(){
return 0;
}
}
/**
*
* This class simulates a Deque, which is a data structure that insert and remove data
* by FILO (first-in, last-out) rule
*
*/
class Deque extends Queue{
/**
* This is the constructor that initializes the <code> deque </code>
*/
public Deque() {
}
/**
* This method adds an object to the deque treated as a stack.
* Please note that the rule of the deque insertion/removal is
* both First in, first out (FIFO), as well as Last in, First out (LIFO)
*/
public void push(Object obj) {
}
/**
* This method removes an object from the deque treated as a stack.
* Please note that the rule of the deque insertion/removal is
* both First in, first out (FIFO), as well as Last in, First out (LIFO)
*/
public Object pop() {
return null;
}
}

More Related Content

Similar to A generic queue is a general queue storage that can store an.pdf

we using java code DynamicArrayjava Replace all .pdf
we using java code   DynamicArrayjava   Replace all .pdfwe using java code   DynamicArrayjava   Replace all .pdf
we using java code DynamicArrayjava Replace all .pdf
gudduraza28
 
JAVAneed help with public IteratorItem iterator()import java.u.pdf
JAVAneed help with public IteratorItem iterator()import java.u.pdfJAVAneed help with public IteratorItem iterator()import java.u.pdf
JAVAneed help with public IteratorItem iterator()import java.u.pdf
fcsondhiindia
 
A linked stack is implemented using a standard Node class as follows.pdf
A linked stack is implemented using a standard Node class as follows.pdfA linked stack is implemented using a standard Node class as follows.pdf
A linked stack is implemented using a standard Node class as follows.pdf
kisgstin23
 
UNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
UNIT-2.pptx CS3391 Inheritance , types, packages and InterfacesUNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
UNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
SakkaravarthiS1
 
Java Programming - 04 object oriented in java
Java Programming - 04 object oriented in javaJava Programming - 04 object oriented in java
Java Programming - 04 object oriented in java
Danairat Thanabodithammachari
 
Python for Beginners
Python  for BeginnersPython  for Beginners
Python for Beginners
DrRShaliniVISTAS
 
Given the following ADT definition of a stack to use stack .docx
Given the following ADT definition of a stack to use stack .docxGiven the following ADT definition of a stack to use stack .docx
Given the following ADT definition of a stack to use stack .docx
shericehewat
 
please read below it will tell you what we are using L.pdf
please read below it will tell you what we are using   L.pdfplease read below it will tell you what we are using   L.pdf
please read below it will tell you what we are using L.pdf
ankit11134
 
UNIT_-II_2021R.pptx
UNIT_-II_2021R.pptxUNIT_-II_2021R.pptx
UNIT_-II_2021R.pptx
RDeepa9
 
Stack Implementation
Stack ImplementationStack Implementation
Stack Implementation
Zidny Nafan
 
Please do parts labeled TODO LinkedList.java Replace.pdf
Please do parts labeled TODO LinkedList.java Replace.pdfPlease do parts labeled TODO LinkedList.java Replace.pdf
Please do parts labeled TODO LinkedList.java Replace.pdf
aioils
 
Java Concepts
Java ConceptsJava Concepts
Java Concepts
AbdulImrankhan7
 
please read the steps below and it will tell you what we usi.pdf
please read the steps below and it will tell you what we usi.pdfplease read the steps below and it will tell you what we usi.pdf
please read the steps below and it will tell you what we usi.pdf
aggarwalopticalsco
 
Core java
Core javaCore java
Core java
Rajkattamuri
 
2 b queues
2 b queues2 b queues
2 b queues
Nguync91368
 
Classes, Objects and Method - Object Oriented Programming with Java
Classes, Objects and Method - Object Oriented Programming with JavaClasses, Objects and Method - Object Oriented Programming with Java
Classes, Objects and Method - Object Oriented Programming with Java
Radhika Talaviya
 
List in java
List in javaList in java
List in java
nitin kumar
 
How do I fix it in LinkedList.javathis is what i didLabProgra.pdf
How do I fix it in LinkedList.javathis is what i didLabProgra.pdfHow do I fix it in LinkedList.javathis is what i didLabProgra.pdf
How do I fix it in LinkedList.javathis is what i didLabProgra.pdf
mail931892
 
Best Core Java Training In Bangalore
Best Core Java Training In BangaloreBest Core Java Training In Bangalore
Best Core Java Training In Bangalore
rajkamaltibacademy
 
Java Generics
Java GenericsJava Generics
Java Generics
jeslie
 

Similar to A generic queue is a general queue storage that can store an.pdf (20)

we using java code DynamicArrayjava Replace all .pdf
we using java code   DynamicArrayjava   Replace all .pdfwe using java code   DynamicArrayjava   Replace all .pdf
we using java code DynamicArrayjava Replace all .pdf
 
JAVAneed help with public IteratorItem iterator()import java.u.pdf
JAVAneed help with public IteratorItem iterator()import java.u.pdfJAVAneed help with public IteratorItem iterator()import java.u.pdf
JAVAneed help with public IteratorItem iterator()import java.u.pdf
 
A linked stack is implemented using a standard Node class as follows.pdf
A linked stack is implemented using a standard Node class as follows.pdfA linked stack is implemented using a standard Node class as follows.pdf
A linked stack is implemented using a standard Node class as follows.pdf
 
UNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
UNIT-2.pptx CS3391 Inheritance , types, packages and InterfacesUNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
UNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
 
Java Programming - 04 object oriented in java
Java Programming - 04 object oriented in javaJava Programming - 04 object oriented in java
Java Programming - 04 object oriented in java
 
Python for Beginners
Python  for BeginnersPython  for Beginners
Python for Beginners
 
Given the following ADT definition of a stack to use stack .docx
Given the following ADT definition of a stack to use stack .docxGiven the following ADT definition of a stack to use stack .docx
Given the following ADT definition of a stack to use stack .docx
 
please read below it will tell you what we are using L.pdf
please read below it will tell you what we are using   L.pdfplease read below it will tell you what we are using   L.pdf
please read below it will tell you what we are using L.pdf
 
UNIT_-II_2021R.pptx
UNIT_-II_2021R.pptxUNIT_-II_2021R.pptx
UNIT_-II_2021R.pptx
 
Stack Implementation
Stack ImplementationStack Implementation
Stack Implementation
 
Please do parts labeled TODO LinkedList.java Replace.pdf
Please do parts labeled TODO LinkedList.java Replace.pdfPlease do parts labeled TODO LinkedList.java Replace.pdf
Please do parts labeled TODO LinkedList.java Replace.pdf
 
Java Concepts
Java ConceptsJava Concepts
Java Concepts
 
please read the steps below and it will tell you what we usi.pdf
please read the steps below and it will tell you what we usi.pdfplease read the steps below and it will tell you what we usi.pdf
please read the steps below and it will tell you what we usi.pdf
 
Core java
Core javaCore java
Core java
 
2 b queues
2 b queues2 b queues
2 b queues
 
Classes, Objects and Method - Object Oriented Programming with Java
Classes, Objects and Method - Object Oriented Programming with JavaClasses, Objects and Method - Object Oriented Programming with Java
Classes, Objects and Method - Object Oriented Programming with Java
 
List in java
List in javaList in java
List in java
 
How do I fix it in LinkedList.javathis is what i didLabProgra.pdf
How do I fix it in LinkedList.javathis is what i didLabProgra.pdfHow do I fix it in LinkedList.javathis is what i didLabProgra.pdf
How do I fix it in LinkedList.javathis is what i didLabProgra.pdf
 
Best Core Java Training In Bangalore
Best Core Java Training In BangaloreBest Core Java Training In Bangalore
Best Core Java Training In Bangalore
 
Java Generics
Java GenericsJava Generics
Java Generics
 

More from ADITIHERBAL

A ince barsakta ya emlsifikasyon sreci B dklamay dzenl.pdf
A ince barsakta ya emlsifikasyon sreci  B dklamay dzenl.pdfA ince barsakta ya emlsifikasyon sreci  B dklamay dzenl.pdf
A ince barsakta ya emlsifikasyon sreci B dklamay dzenl.pdf
ADITIHERBAL
 
A is a nonempty set and G is a finite group that can be see.pdf
A is a nonempty set and G is a finite group that can be see.pdfA is a nonempty set and G is a finite group that can be see.pdf
A is a nonempty set and G is a finite group that can be see.pdf
ADITIHERBAL
 
a In a punctuated module new species change most as they .pdf
a In a punctuated module new species change most as they .pdfa In a punctuated module new species change most as they .pdf
a In a punctuated module new species change most as they .pdf
ADITIHERBAL
 
A Imagine you are a communication consultant giving advice .pdf
A Imagine you are a communication consultant giving advice .pdfA Imagine you are a communication consultant giving advice .pdf
A Imagine you are a communication consultant giving advice .pdf
ADITIHERBAL
 
A group of college DJs surveyed students to find out what mu.pdf
A group of college DJs surveyed students to find out what mu.pdfA group of college DJs surveyed students to find out what mu.pdf
A group of college DJs surveyed students to find out what mu.pdf
ADITIHERBAL
 
A health system has forecast net patient revenue in the firs.pdf
A health system has forecast net patient revenue in the firs.pdfA health system has forecast net patient revenue in the firs.pdf
A health system has forecast net patient revenue in the firs.pdf
ADITIHERBAL
 
A gene which is 1440 bp long codes for polypeptide that is 1.pdf
A gene which is 1440 bp long codes for polypeptide that is 1.pdfA gene which is 1440 bp long codes for polypeptide that is 1.pdf
A gene which is 1440 bp long codes for polypeptide that is 1.pdf
ADITIHERBAL
 
a Identificar y discutir los factores bsicos de comunicaci.pdf
a Identificar y discutir los factores bsicos de comunicaci.pdfa Identificar y discutir los factores bsicos de comunicaci.pdf
a Identificar y discutir los factores bsicos de comunicaci.pdf
ADITIHERBAL
 
A Health Behaviour in Schoolaged Children study found that .pdf
A Health Behaviour in Schoolaged Children study found that .pdfA Health Behaviour in Schoolaged Children study found that .pdf
A Health Behaviour in Schoolaged Children study found that .pdf
ADITIHERBAL
 
a Identify all NE throughout 3 you are only required to p.pdf
a Identify all NE throughout 3 you are only required to p.pdfa Identify all NE throughout 3 you are only required to p.pdf
a Identify all NE throughout 3 you are only required to p.pdf
ADITIHERBAL
 
A hoverboard is a levitating board similar in shape and size.pdf
A hoverboard is a levitating board similar in shape and size.pdfA hoverboard is a levitating board similar in shape and size.pdf
A hoverboard is a levitating board similar in shape and size.pdf
ADITIHERBAL
 
A hospital is trying to cut down on emergency room wait time.pdf
A hospital is trying to cut down on emergency room wait time.pdfA hospital is trying to cut down on emergency room wait time.pdf
A hospital is trying to cut down on emergency room wait time.pdf
ADITIHERBAL
 
A healthy female Labrador retriever was mated with two healt.pdf
A healthy female Labrador retriever was mated with two healt.pdfA healthy female Labrador retriever was mated with two healt.pdf
A healthy female Labrador retriever was mated with two healt.pdf
ADITIHERBAL
 
A hypertonic solution is prepared by the addition of sucrose.pdf
A hypertonic solution is prepared by the addition of sucrose.pdfA hypertonic solution is prepared by the addition of sucrose.pdf
A hypertonic solution is prepared by the addition of sucrose.pdf
ADITIHERBAL
 
A group of n people were removed from the hotel After a mon.pdf
A group of n people were removed from the hotel After a mon.pdfA group of n people were removed from the hotel After a mon.pdf
A group of n people were removed from the hotel After a mon.pdf
ADITIHERBAL
 
A group of employees of Unique Services will be surveyed abo.pdf
A group of employees of Unique Services will be surveyed abo.pdfA group of employees of Unique Services will be surveyed abo.pdf
A group of employees of Unique Services will be surveyed abo.pdf
ADITIHERBAL
 
A Genler aras sekanslar insan genomunun gt60n oluturur.pdf
A Genler aras sekanslar insan genomunun gt60n oluturur.pdfA Genler aras sekanslar insan genomunun gt60n oluturur.pdf
A Genler aras sekanslar insan genomunun gt60n oluturur.pdf
ADITIHERBAL
 
a Given that XX1X2Xn represents a random sample of .pdf
a Given that XX1X2Xn represents a random sample of .pdfa Given that XX1X2Xn represents a random sample of .pdf
a Given that XX1X2Xn represents a random sample of .pdf
ADITIHERBAL
 
A genetic disorder shows cytoplasmic inheritance A heteropl.pdf
A genetic disorder shows cytoplasmic inheritance A heteropl.pdfA genetic disorder shows cytoplasmic inheritance A heteropl.pdf
A genetic disorder shows cytoplasmic inheritance A heteropl.pdf
ADITIHERBAL
 
A formal often temporary partnership involving two or more.pdf
A formal often temporary partnership involving two or more.pdfA formal often temporary partnership involving two or more.pdf
A formal often temporary partnership involving two or more.pdf
ADITIHERBAL
 

More from ADITIHERBAL (20)

A ince barsakta ya emlsifikasyon sreci B dklamay dzenl.pdf
A ince barsakta ya emlsifikasyon sreci  B dklamay dzenl.pdfA ince barsakta ya emlsifikasyon sreci  B dklamay dzenl.pdf
A ince barsakta ya emlsifikasyon sreci B dklamay dzenl.pdf
 
A is a nonempty set and G is a finite group that can be see.pdf
A is a nonempty set and G is a finite group that can be see.pdfA is a nonempty set and G is a finite group that can be see.pdf
A is a nonempty set and G is a finite group that can be see.pdf
 
a In a punctuated module new species change most as they .pdf
a In a punctuated module new species change most as they .pdfa In a punctuated module new species change most as they .pdf
a In a punctuated module new species change most as they .pdf
 
A Imagine you are a communication consultant giving advice .pdf
A Imagine you are a communication consultant giving advice .pdfA Imagine you are a communication consultant giving advice .pdf
A Imagine you are a communication consultant giving advice .pdf
 
A group of college DJs surveyed students to find out what mu.pdf
A group of college DJs surveyed students to find out what mu.pdfA group of college DJs surveyed students to find out what mu.pdf
A group of college DJs surveyed students to find out what mu.pdf
 
A health system has forecast net patient revenue in the firs.pdf
A health system has forecast net patient revenue in the firs.pdfA health system has forecast net patient revenue in the firs.pdf
A health system has forecast net patient revenue in the firs.pdf
 
A gene which is 1440 bp long codes for polypeptide that is 1.pdf
A gene which is 1440 bp long codes for polypeptide that is 1.pdfA gene which is 1440 bp long codes for polypeptide that is 1.pdf
A gene which is 1440 bp long codes for polypeptide that is 1.pdf
 
a Identificar y discutir los factores bsicos de comunicaci.pdf
a Identificar y discutir los factores bsicos de comunicaci.pdfa Identificar y discutir los factores bsicos de comunicaci.pdf
a Identificar y discutir los factores bsicos de comunicaci.pdf
 
A Health Behaviour in Schoolaged Children study found that .pdf
A Health Behaviour in Schoolaged Children study found that .pdfA Health Behaviour in Schoolaged Children study found that .pdf
A Health Behaviour in Schoolaged Children study found that .pdf
 
a Identify all NE throughout 3 you are only required to p.pdf
a Identify all NE throughout 3 you are only required to p.pdfa Identify all NE throughout 3 you are only required to p.pdf
a Identify all NE throughout 3 you are only required to p.pdf
 
A hoverboard is a levitating board similar in shape and size.pdf
A hoverboard is a levitating board similar in shape and size.pdfA hoverboard is a levitating board similar in shape and size.pdf
A hoverboard is a levitating board similar in shape and size.pdf
 
A hospital is trying to cut down on emergency room wait time.pdf
A hospital is trying to cut down on emergency room wait time.pdfA hospital is trying to cut down on emergency room wait time.pdf
A hospital is trying to cut down on emergency room wait time.pdf
 
A healthy female Labrador retriever was mated with two healt.pdf
A healthy female Labrador retriever was mated with two healt.pdfA healthy female Labrador retriever was mated with two healt.pdf
A healthy female Labrador retriever was mated with two healt.pdf
 
A hypertonic solution is prepared by the addition of sucrose.pdf
A hypertonic solution is prepared by the addition of sucrose.pdfA hypertonic solution is prepared by the addition of sucrose.pdf
A hypertonic solution is prepared by the addition of sucrose.pdf
 
A group of n people were removed from the hotel After a mon.pdf
A group of n people were removed from the hotel After a mon.pdfA group of n people were removed from the hotel After a mon.pdf
A group of n people were removed from the hotel After a mon.pdf
 
A group of employees of Unique Services will be surveyed abo.pdf
A group of employees of Unique Services will be surveyed abo.pdfA group of employees of Unique Services will be surveyed abo.pdf
A group of employees of Unique Services will be surveyed abo.pdf
 
A Genler aras sekanslar insan genomunun gt60n oluturur.pdf
A Genler aras sekanslar insan genomunun gt60n oluturur.pdfA Genler aras sekanslar insan genomunun gt60n oluturur.pdf
A Genler aras sekanslar insan genomunun gt60n oluturur.pdf
 
a Given that XX1X2Xn represents a random sample of .pdf
a Given that XX1X2Xn represents a random sample of .pdfa Given that XX1X2Xn represents a random sample of .pdf
a Given that XX1X2Xn represents a random sample of .pdf
 
A genetic disorder shows cytoplasmic inheritance A heteropl.pdf
A genetic disorder shows cytoplasmic inheritance A heteropl.pdfA genetic disorder shows cytoplasmic inheritance A heteropl.pdf
A genetic disorder shows cytoplasmic inheritance A heteropl.pdf
 
A formal often temporary partnership involving two or more.pdf
A formal often temporary partnership involving two or more.pdfA formal often temporary partnership involving two or more.pdf
A formal often temporary partnership involving two or more.pdf
 

Recently uploaded

The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
Himanshu Rai
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
สมใจ จันสุกสี
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
Wahiba Chair Training & Consulting
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Diana Rendina
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
TechSoup
 

Recently uploaded (20)

The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
 

A generic queue is a general queue storage that can store an.pdf

  • 1. A generic queue is a general queue storage that can store an unlimited number of objects. In this lab, you need to implement two types of the generic queue including Queue and Deque. The Java code of this module includes a class that represent Queues and was mentioned briefly during the lecture, therefore if you need to, please revisit the java code. The second special type of containers is called a Deque. A deque is a special type of queue that is double ended. It means that elements can be added to the queue at both ends and removing can be from both ends. In essence, a deque follows both a FIFO (First in, First out) and a LIFO (Last In, First Out) rules to insert/remove from/to the queue. This means that a deque can play the role of a queue and a stack at the same time. You can imagine a stack as a plate dispenser. When you add a plate, you add it to the top of the dispenser. When you remove a plate, you remove it from the top again. However, for a queue, you can imagine a queue of students waiting in line. The first student who comes into the line is the first student served and hence removed from the line. For the stack behavior of a deque, there are two main and two auxiliary methods: push(object): This method adds the object to the stack. IN other words, the object is added at the front. pop(): removes the last element that was added, from the stack. In other words, the object is removed from the front. top(): returns the element, which is at the top of the stack, without removing it. getSize(): returns the number of elements in the stack. Your job for this lab, is to complete GenericQueue, Queue and Deque class. I have written a comment, where you need to insert your code. 3.1. Class GenericQueue The names of the methods in this class explain themselves. If you need more clarification, please read the javaDoc for these methods. 3.2. Class Queue While Queue Is-A generic queue, it follows the rule of Queue data structure (FIFO), therefore all the methods should be implemented in a way that the rule is followed. This class has an instance variable that holds all the items. The rest of the methods are self- explanatory. 3.3. Class Deque The Deque class is a special type of a Queue that was explained above. So the deque acts as a queue and has additional methods that represent the stack behaviour. This class has a constructor that uses the list that contains the data. To implement the rest of the methods see their javaDoc. import java.util.*; import java.io.*; /** * This class is a GenericQueue that holds an unlimited number of * objects. It is able to remove objects and add objects. */ public class GenericQueue { // No instance variable should be defined for this class.
  • 2. /** * This method adds the <code> obj </code> to the GenericQueue. * @param obj is the object that is added to the GenericQueue. */ void add(Object object) { // insert your code here } /** * This method removes the object from the GenericQueue * @return returns the removed object. */ Object remove() { // insert your code here. You may want to change the return value. return null; } /** * @return It returns the number of elements in the GenericQueue. */ int getSize() { // insert your code here. You may need to change the return value. return 0; } } /** * * This class simulates a Queue, which is a data structure that insert and remove data * by FIFO (first-in, first-out) rule * */ class Queue extends GenericQueue{ ArrayList<Object> queue; /** * This is the constructor that initializes the <code> queue </code> */ public Queue() { } /** * This method adds the object into the Queue.
  • 3. * Please note that the rule of the queue insertion/removal is * First in, First out. * @param obj is the object that is added to the queue. */ @Override public void add(Object obj) { } /** * This method removes an object from the Queue. * Please note that the rule of the queue insertion/removal is * First in, First out. */ @Override public Object remove() { return null; } /** * @return returns the object which is in front of the queue. */ public Object top() { return null; } /** * Returns the number of items in the queue. */ @Override public int getSize(){ return 0; } } /** * * This class simulates a Deque, which is a data structure that insert and remove data * by FILO (first-in, last-out) rule * */ class Deque extends Queue{ /** * This is the constructor that initializes the <code> deque </code>
  • 4. */ public Deque() { } /** * This method adds an object to the deque treated as a stack. * Please note that the rule of the deque insertion/removal is * both First in, first out (FIFO), as well as Last in, First out (LIFO) */ public void push(Object obj) { } /** * This method removes an object from the deque treated as a stack. * Please note that the rule of the deque insertion/removal is * both First in, first out (FIFO), as well as Last in, First out (LIFO) */ public Object pop() { return null; } } import java.util.*; import java.io.*; /** * This class is a GenericQueue that holds an unlimited number of * objects. It is able to remove objects and add objects. */ public class GenericQueue { // No instance variable should be defined for this class. /** * This method adds the <code> obj </code> to the GenericQueue. * @param obj is the object that is added to the GenericQueue. */ void add(Object object) { // insert your code here } /** * This method removes the object from the GenericQueue
  • 5. * @return returns the removed object. */ Object remove() { // insert your code here. You may want to change the return value. return null; } /** * @return It returns the number of elements in the GenericQueue. */ int getSize() { // insert your code here. You may need to change the return value. return 0; } } /** * * This class simulates a Queue, which is a data structure that insert and remove data * by FIFO (first-in, first-out) rule * */ class Queue extends GenericQueue{ ArrayList<Object> queue; /** * This is the constructor that initializes the <code> queue </code> */ public Queue() { } /** * This method adds the object into the Queue. * Please note that the rule of the queue insertion/removal is * First in, First out. * @param obj is the object that is added to the queue. */ @Override public void add(Object obj) { } /** * This method removes an object from the Queue.
  • 6. * Please note that the rule of the queue insertion/removal is * First in, First out. */ @Override public Object remove() { return null; } /** * @return returns the object which is in front of the queue. */ public Object top() { return null; } /** * Returns the number of items in the queue. */ @Override public int getSize(){ return 0; } } /** * * This class simulates a Deque, which is a data structure that insert and remove data * by FILO (first-in, last-out) rule * */ class Deque extends Queue{ /** * This is the constructor that initializes the <code> deque </code> */ public Deque() { } /** * This method adds an object to the deque treated as a stack. * Please note that the rule of the deque insertion/removal is * both First in, first out (FIFO), as well as Last in, First out (LIFO) */
  • 7. public void push(Object obj) { } /** * This method removes an object from the deque treated as a stack. * Please note that the rule of the deque insertion/removal is * both First in, first out (FIFO), as well as Last in, First out (LIFO) */ public Object pop() { return null; } }