SlideShare a Scribd company logo
1 of 2
Given the following Queue definition: public class Queue { private char [] data; private int front,
back, size; public Queue() { ...} public void enqueue(char item) { ...} public char dequeueQ { ...}
public String toString() { ...} public boolean isEmpty() Write a method for Queue that
determines if this Queue is equal to another Queue. It should return a boolean value indicating
whether or not the two sets have the same contents. Remember, the order of the items in the two
sets could be different! public boolean equals(Queue other) {}
Solution
Answer:)
// equals: returns true if this is identical to Q, false otherwise.
public boolean equals(Queue Q){
if(this.length != Q.length)
{
return false;
}
boolean flag = true;
Node N = this.front;
Node M = Q.front;
while( flag && N != null){
flag = (N.data==M.data);
N = N.next;
M = M.next;
}
return flag;
}
Given the following Queue definition- public class Queue { private cha (1).docx

More Related Content

Similar to Given the following Queue definition- public class Queue { private cha (1).docx

Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data StructureSriram Raj
 
Can someone help me please I need help writing this code using Java.pdf
Can someone help me please I need help writing this code using Java.pdfCan someone help me please I need help writing this code using Java.pdf
Can someone help me please I need help writing this code using Java.pdfmarketing413921
 
assignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docx
assignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docxassignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docx
assignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docxssuser562afc1
 
Scala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 WorldScala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 WorldBTI360
 
Built in classes in java
Built in classes in javaBuilt in classes in java
Built in classes in javaMahmoud Ali
 
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdfModify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdfarjuncorner565
 
Programing with java for begniers .pptx
Programing with java for begniers  .pptxPrograming with java for begniers  .pptx
Programing with java for begniers .pptxadityaraj7711
 
SpreadsheetWriter.javaCan you please help me the JAVA program Let.pdf
SpreadsheetWriter.javaCan you please help me the JAVA program Let.pdfSpreadsheetWriter.javaCan you please help me the JAVA program Let.pdf
SpreadsheetWriter.javaCan you please help me the JAVA program Let.pdfezonesolutions
 
package algs13;import stdlib.;import java.util.Iterator;im.docx
package algs13;import  stdlib.;import java.util.Iterator;im.docxpackage algs13;import  stdlib.;import java.util.Iterator;im.docx
package algs13;import stdlib.;import java.util.Iterator;im.docxgerardkortney
 
usingpackage util;import java.util.;This class implements.pdf
usingpackage util;import java.util.;This class implements.pdfusingpackage util;import java.util.;This class implements.pdf
usingpackage util;import java.util.;This class implements.pdfinfo335653
 

Similar to Given the following Queue definition- public class Queue { private cha (1).docx (19)

Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
Can someone help me please I need help writing this code using Java.pdf
Can someone help me please I need help writing this code using Java.pdfCan someone help me please I need help writing this code using Java.pdf
Can someone help me please I need help writing this code using Java.pdf
 
assignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docx
assignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docxassignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docx
assignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docx
 
class object.pptx
class object.pptxclass object.pptx
class object.pptx
 
Scala in practice
Scala in practiceScala in practice
Scala in practice
 
‫Chapter3 inheritance
‫Chapter3 inheritance‫Chapter3 inheritance
‫Chapter3 inheritance
 
Second chapter-java
Second chapter-javaSecond chapter-java
Second chapter-java
 
Scala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 WorldScala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 World
 
Java Class Design
Java Class DesignJava Class Design
Java Class Design
 
Built in classes in java
Built in classes in javaBuilt in classes in java
Built in classes in java
 
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdfModify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
 
Programing with java for begniers .pptx
Programing with java for begniers  .pptxPrograming with java for begniers  .pptx
Programing with java for begniers .pptx
 
Stack and queue
Stack and queueStack and queue
Stack and queue
 
SpreadsheetWriter.javaCan you please help me the JAVA program Let.pdf
SpreadsheetWriter.javaCan you please help me the JAVA program Let.pdfSpreadsheetWriter.javaCan you please help me the JAVA program Let.pdf
SpreadsheetWriter.javaCan you please help me the JAVA program Let.pdf
 
package algs13;import stdlib.;import java.util.Iterator;im.docx
package algs13;import  stdlib.;import java.util.Iterator;im.docxpackage algs13;import  stdlib.;import java.util.Iterator;im.docx
package algs13;import stdlib.;import java.util.Iterator;im.docx
 
JUnit PowerUp
JUnit PowerUpJUnit PowerUp
JUnit PowerUp
 
Built-in Classes in JAVA
Built-in Classes in JAVABuilt-in Classes in JAVA
Built-in Classes in JAVA
 
Computer programming 2 Lesson 11
Computer programming 2  Lesson 11Computer programming 2  Lesson 11
Computer programming 2 Lesson 11
 
usingpackage util;import java.util.;This class implements.pdf
usingpackage util;import java.util.;This class implements.pdfusingpackage util;import java.util.;This class implements.pdf
usingpackage util;import java.util.;This class implements.pdf
 

More from rtodd751

Given an unsorted linked list- how to find the minimum element-Solutio.docx
Given an unsorted linked list- how to find the minimum element-Solutio.docxGiven an unsorted linked list- how to find the minimum element-Solutio.docx
Given an unsorted linked list- how to find the minimum element-Solutio.docxrtodd751
 
Given the following Binary Tree- show the box trace of Depth(N)-Soluti.docx
Given the following Binary Tree- show the box trace of Depth(N)-Soluti.docxGiven the following Binary Tree- show the box trace of Depth(N)-Soluti.docx
Given the following Binary Tree- show the box trace of Depth(N)-Soluti.docxrtodd751
 
Given the following class declaration- write the code in Java for the.docx
Given the following class declaration- write the code in Java for the.docxGiven the following class declaration- write the code in Java for the.docx
Given the following class declaration- write the code in Java for the.docxrtodd751
 
Given a list of numbers- count and return how many pairs there are- A.docx
Given a list of numbers- count and return how many pairs there are- A.docxGiven a list of numbers- count and return how many pairs there are- A.docx
Given a list of numbers- count and return how many pairs there are- A.docxrtodd751
 
Given 5 moles of H2SO4 react with excess NaOH how many moles of water.docx
Given 5 moles of H2SO4 react with excess NaOH how many moles of water.docxGiven 5 moles of H2SO4 react with excess NaOH how many moles of water.docx
Given 5 moles of H2SO4 react with excess NaOH how many moles of water.docxrtodd751
 
Given an unsorted linked list- how to find the minimum element-Solutio (1).docx
Given an unsorted linked list- how to find the minimum element-Solutio (1).docxGiven an unsorted linked list- how to find the minimum element-Solutio (1).docx
Given an unsorted linked list- how to find the minimum element-Solutio (1).docxrtodd751
 
Give five latest and uncommon research topics in intelligent vehicular.docx
Give five latest and uncommon research topics in intelligent vehicular.docxGive five latest and uncommon research topics in intelligent vehicular.docx
Give five latest and uncommon research topics in intelligent vehicular.docxrtodd751
 
Give and explain the periodic trend of atomic radius for the 3rd perio.docx
Give and explain the periodic trend of atomic radius for the 3rd perio.docxGive and explain the periodic trend of atomic radius for the 3rd perio.docx
Give and explain the periodic trend of atomic radius for the 3rd perio.docxrtodd751
 
Give an example of a business objective and the related Key Performanc.docx
Give an example of a business objective and the related Key Performanc.docxGive an example of a business objective and the related Key Performanc.docx
Give an example of a business objective and the related Key Performanc.docxrtodd751
 
General Motors exports cars to Spain- but the strong dollar against th.docx
General Motors exports cars to Spain- but the strong dollar against th.docxGeneral Motors exports cars to Spain- but the strong dollar against th.docx
General Motors exports cars to Spain- but the strong dollar against th.docxrtodd751
 

More from rtodd751 (10)

Given an unsorted linked list- how to find the minimum element-Solutio.docx
Given an unsorted linked list- how to find the minimum element-Solutio.docxGiven an unsorted linked list- how to find the minimum element-Solutio.docx
Given an unsorted linked list- how to find the minimum element-Solutio.docx
 
Given the following Binary Tree- show the box trace of Depth(N)-Soluti.docx
Given the following Binary Tree- show the box trace of Depth(N)-Soluti.docxGiven the following Binary Tree- show the box trace of Depth(N)-Soluti.docx
Given the following Binary Tree- show the box trace of Depth(N)-Soluti.docx
 
Given the following class declaration- write the code in Java for the.docx
Given the following class declaration- write the code in Java for the.docxGiven the following class declaration- write the code in Java for the.docx
Given the following class declaration- write the code in Java for the.docx
 
Given a list of numbers- count and return how many pairs there are- A.docx
Given a list of numbers- count and return how many pairs there are- A.docxGiven a list of numbers- count and return how many pairs there are- A.docx
Given a list of numbers- count and return how many pairs there are- A.docx
 
Given 5 moles of H2SO4 react with excess NaOH how many moles of water.docx
Given 5 moles of H2SO4 react with excess NaOH how many moles of water.docxGiven 5 moles of H2SO4 react with excess NaOH how many moles of water.docx
Given 5 moles of H2SO4 react with excess NaOH how many moles of water.docx
 
Given an unsorted linked list- how to find the minimum element-Solutio (1).docx
Given an unsorted linked list- how to find the minimum element-Solutio (1).docxGiven an unsorted linked list- how to find the minimum element-Solutio (1).docx
Given an unsorted linked list- how to find the minimum element-Solutio (1).docx
 
Give five latest and uncommon research topics in intelligent vehicular.docx
Give five latest and uncommon research topics in intelligent vehicular.docxGive five latest and uncommon research topics in intelligent vehicular.docx
Give five latest and uncommon research topics in intelligent vehicular.docx
 
Give and explain the periodic trend of atomic radius for the 3rd perio.docx
Give and explain the periodic trend of atomic radius for the 3rd perio.docxGive and explain the periodic trend of atomic radius for the 3rd perio.docx
Give and explain the periodic trend of atomic radius for the 3rd perio.docx
 
Give an example of a business objective and the related Key Performanc.docx
Give an example of a business objective and the related Key Performanc.docxGive an example of a business objective and the related Key Performanc.docx
Give an example of a business objective and the related Key Performanc.docx
 
General Motors exports cars to Spain- but the strong dollar against th.docx
General Motors exports cars to Spain- but the strong dollar against th.docxGeneral Motors exports cars to Spain- but the strong dollar against th.docx
General Motors exports cars to Spain- but the strong dollar against th.docx
 

Recently uploaded

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 

Recently uploaded (20)

INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 

Given the following Queue definition- public class Queue { private cha (1).docx

  • 1. Given the following Queue definition: public class Queue { private char [] data; private int front, back, size; public Queue() { ...} public void enqueue(char item) { ...} public char dequeueQ { ...} public String toString() { ...} public boolean isEmpty() Write a method for Queue that determines if this Queue is equal to another Queue. It should return a boolean value indicating whether or not the two sets have the same contents. Remember, the order of the items in the two sets could be different! public boolean equals(Queue other) {} Solution Answer:) // equals: returns true if this is identical to Q, false otherwise. public boolean equals(Queue Q){ if(this.length != Q.length) { return false; } boolean flag = true; Node N = this.front; Node M = Q.front; while( flag && N != null){ flag = (N.data==M.data); N = N.next; M = M.next; } return flag; }