SlideShare ist ein Scribd-Unternehmen logo
1 von 1
Downloaden Sie, um offline zu lesen
ArrayQ // finish the methods
LinkedQ// finish methods
Qinterface
class that implements the ADT queue by using a resizable circular array. ic final class
ArrayQueue T implements QueueInterface T { private T [ ] queue; // Circular array of queue
entries private int frontindex; // Index of front entry // No need to keep track of the backIndex
because... // The back index can be calculated from (frontindex + size) 5 queue.length // Plus,
there is only one place in the code where we really need the back inde private int size; private
static final int DEFAULT_CAPACITY = 10; port java.util.NosuchElementException; A class
that implements the ADT queue by using a chain of linked nodes that has references to the front
and end of the chain. Adds will be after the last node. Removes will be from the front node. blic
final class LinkedQueue T implements QueueInterface T { private Node firstNode; // References
node at front of queue private Node lastNode; // References node at back of queue public
LinkedQueue() { firstNode = null lastiode = null; 3 // end default constructor public void add( T
newentry) { // TODO 3 // end enqueue public T peek() { if (isempty()) throw new
NosuchelementException(); else return firstNode.data; 3 // end getFront public T remove() { //
TODO T frontbata = peek (); // Might throw NoSuchElementException return frontData; 3 // end
dequeue public boolean isempty() { // TODO return false; 3 // end isEmpty public void clear() {
// TODO 3 // end clear private class Node { private T data; private Node next; private Node(T
data) { this. data = data; this. next = null; } }

Weitere ähnliche Inhalte

Ähnlich wie ArrayQ -- finish the methods LinkedQ-- finish methods Qinterface class.pdf

Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdfImplement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
kostikjaylonshaewe47
 
1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf
afgt2012
 
#includeiostream#includecstdio#includecstdlibusing names.pdf
#includeiostream#includecstdio#includecstdlibusing names.pdf#includeiostream#includecstdio#includecstdlibusing names.pdf
#includeiostream#includecstdio#includecstdlibusing names.pdf
KUNALHARCHANDANI1
 
Exception to indicate that Singly LinkedList is empty. .pdf
  Exception to indicate that Singly LinkedList is empty. .pdf  Exception to indicate that Singly LinkedList is empty. .pdf
Exception to indicate that Singly LinkedList is empty. .pdf
aravlitraders2012
 
Write a simple program in C (which comiles in gcc a unix environment ).docx
Write a simple program in C (which comiles in gcc a unix environment ).docxWrite a simple program in C (which comiles in gcc a unix environment ).docx
Write a simple program in C (which comiles in gcc a unix environment ).docx
noreendchesterton753
 
Please help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdfPlease help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdf
ankit11134
 
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
 
queuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbb
queuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbbqueuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbb
queuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbb
RAtna29
 
LabProgram.javaimport java.util.NoSuchElementException;public .pdf
LabProgram.javaimport java.util.NoSuchElementException;public .pdfLabProgram.javaimport java.util.NoSuchElementException;public .pdf
LabProgram.javaimport java.util.NoSuchElementException;public .pdf
fantasiatheoutofthef
 
Were writing code for a project that dynamically allocates an arra.pdf
Were writing code for a project that dynamically allocates an arra.pdfWere writing code for a project that dynamically allocates an arra.pdf
Were writing code for a project that dynamically allocates an arra.pdf
fsenterprises
 
How do I fix it in LinkedList.javaLinkedList.java Define.pdf
How do I fix it in LinkedList.javaLinkedList.java Define.pdfHow do I fix it in LinkedList.javaLinkedList.java Define.pdf
How do I fix it in LinkedList.javaLinkedList.java Define.pdf
mail931892
 
java question Fill the add statement areaProject is to wo.pdf
java question Fill the add statement areaProject is to wo.pdfjava question Fill the add statement areaProject is to wo.pdf
java question Fill the add statement areaProject is to wo.pdf
dbrienmhompsonkath75
 

Ähnlich wie ArrayQ -- finish the methods LinkedQ-- finish methods Qinterface class.pdf (20)

Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdfImplement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
 
1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf
 
Algo>Queues
Algo>QueuesAlgo>Queues
Algo>Queues
 
Recursion to iteration automation.
Recursion to iteration automation.Recursion to iteration automation.
Recursion to iteration automation.
 
Stack and Queue
Stack and Queue Stack and Queue
Stack and Queue
 
#includeiostream#includecstdio#includecstdlibusing names.pdf
#includeiostream#includecstdio#includecstdlibusing names.pdf#includeiostream#includecstdio#includecstdlibusing names.pdf
#includeiostream#includecstdio#includecstdlibusing names.pdf
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
Exception to indicate that Singly LinkedList is empty. .pdf
  Exception to indicate that Singly LinkedList is empty. .pdf  Exception to indicate that Singly LinkedList is empty. .pdf
Exception to indicate that Singly LinkedList is empty. .pdf
 
Write a simple program in C (which comiles in gcc a unix environment ).docx
Write a simple program in C (which comiles in gcc a unix environment ).docxWrite a simple program in C (which comiles in gcc a unix environment ).docx
Write a simple program in C (which comiles in gcc a unix environment ).docx
 
Please help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdfPlease help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdf
 
Templates
TemplatesTemplates
Templates
 
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
 
Java Generics
Java GenericsJava Generics
Java Generics
 
queuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbb
queuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbbqueuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbb
queuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbb
 
LabProgram.javaimport java.util.NoSuchElementException;public .pdf
LabProgram.javaimport java.util.NoSuchElementException;public .pdfLabProgram.javaimport java.util.NoSuchElementException;public .pdf
LabProgram.javaimport java.util.NoSuchElementException;public .pdf
 
Creating Interface- Practice Program 6.docx
Creating Interface- Practice Program 6.docxCreating Interface- Practice Program 6.docx
Creating Interface- Practice Program 6.docx
 
Were writing code for a project that dynamically allocates an arra.pdf
Were writing code for a project that dynamically allocates an arra.pdfWere writing code for a project that dynamically allocates an arra.pdf
Were writing code for a project that dynamically allocates an arra.pdf
 
How do I fix it in LinkedList.javaLinkedList.java Define.pdf
How do I fix it in LinkedList.javaLinkedList.java Define.pdfHow do I fix it in LinkedList.javaLinkedList.java Define.pdf
How do I fix it in LinkedList.javaLinkedList.java Define.pdf
 
java question Fill the add statement areaProject is to wo.pdf
java question Fill the add statement areaProject is to wo.pdfjava question Fill the add statement areaProject is to wo.pdf
java question Fill the add statement areaProject is to wo.pdf
 

Mehr von Stewart9OZBondc

B) prepare the entry for the security sale on April 17- 2021- Calculat.pdf
B) prepare the entry for the security sale on April 17- 2021- Calculat.pdfB) prepare the entry for the security sale on April 17- 2021- Calculat.pdf
B) prepare the entry for the security sale on April 17- 2021- Calculat.pdf
Stewart9OZBondc
 
An attacker has sent an email where the victim navigates to a maliciou.pdf
An attacker has sent an email where the victim navigates to a maliciou.pdfAn attacker has sent an email where the victim navigates to a maliciou.pdf
An attacker has sent an email where the victim navigates to a maliciou.pdf
Stewart9OZBondc
 

Mehr von Stewart9OZBondc (20)

Based on the image below- suggest FOUR (4) communication improvements.pdf
Based on the image below- suggest FOUR (4) communication improvements.pdfBased on the image below- suggest FOUR (4) communication improvements.pdf
Based on the image below- suggest FOUR (4) communication improvements.pdf
 
BBB Ine has the following balance sheet and income statement data a- 1.pdf
BBB Ine has the following balance sheet and income statement data a- 1.pdfBBB Ine has the following balance sheet and income statement data a- 1.pdf
BBB Ine has the following balance sheet and income statement data a- 1.pdf
 
Banks and its challenges after the COVID-19 pandemic- In this paper yo.pdf
Banks and its challenges after the COVID-19 pandemic- In this paper yo.pdfBanks and its challenges after the COVID-19 pandemic- In this paper yo.pdf
Banks and its challenges after the COVID-19 pandemic- In this paper yo.pdf
 
Baseball Team Batting Averages Team batting averages for major league.pdf
Baseball Team Batting Averages Team batting averages for major league.pdfBaseball Team Batting Averages Team batting averages for major league.pdf
Baseball Team Batting Averages Team batting averages for major league.pdf
 
Balance Sheet XVZ Corporation December 31-2015 Cash $10-000 Marketable.pdf
Balance Sheet XVZ Corporation December 31-2015 Cash $10-000 Marketable.pdfBalance Sheet XVZ Corporation December 31-2015 Cash $10-000 Marketable.pdf
Balance Sheet XVZ Corporation December 31-2015 Cash $10-000 Marketable.pdf
 
Balance Sheet XYZ Corporation December 31- 2015 Cash Marketable securi.pdf
Balance Sheet XYZ Corporation December 31- 2015 Cash Marketable securi.pdfBalance Sheet XYZ Corporation December 31- 2015 Cash Marketable securi.pdf
Balance Sheet XYZ Corporation December 31- 2015 Cash Marketable securi.pdf
 
As discussed in the book- what are two things the Federal Reserve does.pdf
As discussed in the book- what are two things the Federal Reserve does.pdfAs discussed in the book- what are two things the Federal Reserve does.pdf
As discussed in the book- what are two things the Federal Reserve does.pdf
 
Background- Marfan syndrome is an autosomal dominant trait that leads.pdf
Background- Marfan syndrome is an autosomal dominant trait that leads.pdfBackground- Marfan syndrome is an autosomal dominant trait that leads.pdf
Background- Marfan syndrome is an autosomal dominant trait that leads.pdf
 
B) prepare the entry for the security sale on April 17- 2021- Calculat.pdf
B) prepare the entry for the security sale on April 17- 2021- Calculat.pdfB) prepare the entry for the security sale on April 17- 2021- Calculat.pdf
B) prepare the entry for the security sale on April 17- 2021- Calculat.pdf
 
Arandom sampie of 42 earthquakres that have occurred between danuary 2.pdf
Arandom sampie of 42 earthquakres that have occurred between danuary 2.pdfArandom sampie of 42 earthquakres that have occurred between danuary 2.pdf
Arandom sampie of 42 earthquakres that have occurred between danuary 2.pdf
 
As a member of a team of subject matter experts in the management of e.pdf
As a member of a team of subject matter experts in the management of e.pdfAs a member of a team of subject matter experts in the management of e.pdf
As a member of a team of subject matter experts in the management of e.pdf
 
An example of an epigenetic regulation of gene expression is HDACs- W.pdf
An example of an epigenetic regulation of gene expression is HDACs-  W.pdfAn example of an epigenetic regulation of gene expression is HDACs-  W.pdf
An example of an epigenetic regulation of gene expression is HDACs- W.pdf
 
An direct writing style is NOT used- Group of answer choices A-When.pdf
An direct writing style is NOT used-   Group of answer choices A-When.pdfAn direct writing style is NOT used-   Group of answer choices A-When.pdf
An direct writing style is NOT used- Group of answer choices A-When.pdf
 
An E- coll cell is infected by a temperate phage- Which of the followi.pdf
An E- coll cell is infected by a temperate phage- Which of the followi.pdfAn E- coll cell is infected by a temperate phage- Which of the followi.pdf
An E- coll cell is infected by a temperate phage- Which of the followi.pdf
 
An attacker has sent an email where the victim navigates to a maliciou.pdf
An attacker has sent an email where the victim navigates to a maliciou.pdfAn attacker has sent an email where the victim navigates to a maliciou.pdf
An attacker has sent an email where the victim navigates to a maliciou.pdf
 
An atom has a charge of +2- What does this mean about the relationship.pdf
An atom has a charge of +2- What does this mean about the relationship.pdfAn atom has a charge of +2- What does this mean about the relationship.pdf
An atom has a charge of +2- What does this mean about the relationship.pdf
 
Alisha is proud to be able to send her daughter to university- Her dau.pdf
Alisha is proud to be able to send her daughter to university- Her dau.pdfAlisha is proud to be able to send her daughter to university- Her dau.pdf
Alisha is proud to be able to send her daughter to university- Her dau.pdf
 
An actress has a probability of getting offered a job after a try-out.pdf
An actress has a probability of getting offered a job after a try-out.pdfAn actress has a probability of getting offered a job after a try-out.pdf
An actress has a probability of getting offered a job after a try-out.pdf
 
An adininistrator in the IT-HR department needs access to a virtual ma.pdf
An adininistrator in the IT-HR department needs access to a virtual ma.pdfAn adininistrator in the IT-HR department needs access to a virtual ma.pdf
An adininistrator in the IT-HR department needs access to a virtual ma.pdf
 
Age-specific mortality is defined as thenumber of individuals from the.pdf
Age-specific mortality is defined as thenumber of individuals from the.pdfAge-specific mortality is defined as thenumber of individuals from the.pdf
Age-specific mortality is defined as thenumber of individuals from the.pdf
 

Kürzlich hochgeladen

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Kürzlich hochgeladen (20)

ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 

ArrayQ -- finish the methods LinkedQ-- finish methods Qinterface class.pdf

  • 1. ArrayQ // finish the methods LinkedQ// finish methods Qinterface class that implements the ADT queue by using a resizable circular array. ic final class ArrayQueue T implements QueueInterface T { private T [ ] queue; // Circular array of queue entries private int frontindex; // Index of front entry // No need to keep track of the backIndex because... // The back index can be calculated from (frontindex + size) 5 queue.length // Plus, there is only one place in the code where we really need the back inde private int size; private static final int DEFAULT_CAPACITY = 10; port java.util.NosuchElementException; A class that implements the ADT queue by using a chain of linked nodes that has references to the front and end of the chain. Adds will be after the last node. Removes will be from the front node. blic final class LinkedQueue T implements QueueInterface T { private Node firstNode; // References node at front of queue private Node lastNode; // References node at back of queue public LinkedQueue() { firstNode = null lastiode = null; 3 // end default constructor public void add( T newentry) { // TODO 3 // end enqueue public T peek() { if (isempty()) throw new NosuchelementException(); else return firstNode.data; 3 // end getFront public T remove() { // TODO T frontbata = peek (); // Might throw NoSuchElementException return frontData; 3 // end dequeue public boolean isempty() { // TODO return false; 3 // end isEmpty public void clear() { // TODO 3 // end clear private class Node { private T data; private Node next; private Node(T data) { this. data = data; this. next = null; } }