SlideShare ist ein Scribd-Unternehmen logo
1 von 4
The enqueue operation on the Queue ADT adds a new item to the back of the queue where the
dequeue operation removes and returns the item from the front of the queue. Now consider an
initially empty queue and find the final output for the following sequence of queue operations:
enqueue(7); enqueue(9); enqueue(1); dequeue(); enqueue(8); dequeue(); dequeue(); enqueue(6);
enqueue(3); dequeue(); enqueue(2); enqueue(1); dequeue();
Solution
import java.util.*;
java.io.*;
java.lang.*;
class Queue {
private ArrayList list;
public Queue() {
list = new ArrayList();
}
public void enqueue(Object object) {
if(list.isFull())
System.out.println(“Queue overflowed―);
else
list.add(object);
}
public Object dequeue() {
if(list.isEmpty())
System.out.println(“Queue underflow―);
else
return list.remove(list.size() - 1);
}
public boolean isEmpty() {
return list.isEmpty();
}
public Object front() {
return list.get(list.size() - 1);
}
public Object back() {
return list.get(index);
}
public void clear() {
list.clear();
}
}
class QSample
{
public static void main(String args[]) throws Exception
{
Queue q=new Queue();Â Â Â while(true)
{
System.out.println(" t QUEUE ");
q.enqueue(7);
q.enqueue(9);
q.enqueue(1);
q.back();
q.dequeue();
q.enqueue(8);
q.dequeue();
q.dequeue();
q.enqueue(6);
q.enqueue(3);
q.dequeue();
q.enqueue(2);
q.enqueue(1);
q.dequeue();
System.out.println("Exit");
}
}
}
The Final output is : 3 2 1
The enqueue operation on the Queue ADT adds a new item to the back of (1).docx

Weitere ähnliche Inhalte

Ähnlich wie The enqueue operation on the Queue ADT adds a new item to the back of (1).docx

Writing native bindings to node.js in C++
Writing native bindings to node.js in C++Writing native bindings to node.js in C++
Writing native bindings to node.js in C++nsm.nikhil
 
Stack linked list
Stack linked listStack linked list
Stack linked listbhargav0077
 
Description (Part A) In this lab you will write a Queue implementati.pdf
Description (Part A) In this lab you will write a Queue implementati.pdfDescription (Part A) In this lab you will write a Queue implementati.pdf
Description (Part A) In this lab you will write a Queue implementati.pdfrishabjain5053
 
In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docx
In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docxIn Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docx
In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docxbradburgess22840
 
A topology of memory leaks on the JVM
A topology of memory leaks on the JVMA topology of memory leaks on the JVM
A topology of memory leaks on the JVMRafael Winterhalter
 
Implement the ADT stack by using an array stack to contain its entri.pdf
Implement the ADT stack by using an array stack to contain its entri.pdfImplement the ADT stack by using an array stack to contain its entri.pdf
Implement the ADT stack by using an array stack to contain its entri.pdfSIGMATAX1
 
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
 
Nice to meet Kotlin
Nice to meet KotlinNice to meet Kotlin
Nice to meet KotlinJieyi Wu
 
JJUG CCC 2011 Spring
JJUG CCC 2011 SpringJJUG CCC 2011 Spring
JJUG CCC 2011 SpringKiyotaka Oku
 
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.pdfkisgstin23
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data StructureSriram Raj
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data StructureZidny Nafan
 
queuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbb
queuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbbqueuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbb
queuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbbRAtna29
 
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...julien.ponge
 

Ähnlich wie The enqueue operation on the Queue ADT adds a new item to the back of (1).docx (20)

Writing native bindings to node.js in C++
Writing native bindings to node.js in C++Writing native bindings to node.js in C++
Writing native bindings to node.js in C++
 
Stack linked list
Stack linked listStack linked list
Stack linked list
 
Description (Part A) In this lab you will write a Queue implementati.pdf
Description (Part A) In this lab you will write a Queue implementati.pdfDescription (Part A) In this lab you will write a Queue implementati.pdf
Description (Part A) In this lab you will write a Queue implementati.pdf
 
In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docx
In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docxIn Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docx
In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docx
 
A topology of memory leaks on the JVM
A topology of memory leaks on the JVMA topology of memory leaks on the JVM
A topology of memory leaks on the JVM
 
Lec2
Lec2Lec2
Lec2
 
U3.stack queue
U3.stack queueU3.stack queue
U3.stack queue
 
2 b queues
2 b queues2 b queues
2 b queues
 
LectureNotes-06-DSA
LectureNotes-06-DSALectureNotes-06-DSA
LectureNotes-06-DSA
 
Implement the ADT stack by using an array stack to contain its entri.pdf
Implement the ADT stack by using an array stack to contain its entri.pdfImplement the ADT stack by using an array stack to contain its entri.pdf
Implement the ADT stack by using an array stack to contain its entri.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
 
Nice to meet Kotlin
Nice to meet KotlinNice to meet Kotlin
Nice to meet Kotlin
 
JJUG CCC 2011 Spring
JJUG CCC 2011 SpringJJUG CCC 2011 Spring
JJUG CCC 2011 Spring
 
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
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
Lec2
Lec2Lec2
Lec2
 
queuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbb
queuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbbqueuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbb
queuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbb
 
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
 
stack presentation
stack presentationstack presentation
stack presentation
 

Mehr von carold11

The Financial Management Decision Process What are the three types of.docx
The Financial Management Decision Process What are the three types of.docxThe Financial Management Decision Process What are the three types of.docx
The Financial Management Decision Process What are the three types of.docxcarold11
 
The Federal Reserve attempts to keep prices stable and unemployment lo.docx
The Federal Reserve attempts to keep prices stable and unemployment lo.docxThe Federal Reserve attempts to keep prices stable and unemployment lo.docx
The Federal Reserve attempts to keep prices stable and unemployment lo.docxcarold11
 
The following class stores a list of integer values and contains a met.docx
The following class stores a list of integer values and contains a met.docxThe following class stores a list of integer values and contains a met.docx
The following class stores a list of integer values and contains a met.docxcarold11
 
The following accounts were taken from ABC CompanySolutionCalculation.docx
The following accounts were taken from ABC CompanySolutionCalculation.docxThe following accounts were taken from ABC CompanySolutionCalculation.docx
The following accounts were taken from ABC CompanySolutionCalculation.docxcarold11
 
The following are key terms in Chapter 14 that relate to regulatory an.docx
The following are key terms in Chapter 14 that relate to regulatory an.docxThe following are key terms in Chapter 14 that relate to regulatory an.docx
The following are key terms in Chapter 14 that relate to regulatory an.docxcarold11
 
The following account balances relate to the stockholders equity accou.docx
The following account balances relate to the stockholders equity accou.docxThe following account balances relate to the stockholders equity accou.docx
The following account balances relate to the stockholders equity accou.docxcarold11
 
The following accounts were taken from ABC CompanySolutionCalculation (3).docx
The following accounts were taken from ABC CompanySolutionCalculation (3).docxThe following accounts were taken from ABC CompanySolutionCalculation (3).docx
The following accounts were taken from ABC CompanySolutionCalculation (3).docxcarold11
 
The following accounts were taken from ABC CompanySolutionCalculation (2).docx
The following accounts were taken from ABC CompanySolutionCalculation (2).docxThe following accounts were taken from ABC CompanySolutionCalculation (2).docx
The following accounts were taken from ABC CompanySolutionCalculation (2).docxcarold11
 
The following accounts were taken from ABC CompanySolutionCalculation (1).docx
The following accounts were taken from ABC CompanySolutionCalculation (1).docxThe following accounts were taken from ABC CompanySolutionCalculation (1).docx
The following accounts were taken from ABC CompanySolutionCalculation (1).docxcarold11
 
The fiscal 2012 financial statements of Barney Services shows average.docx
The fiscal 2012 financial statements of Barney Services shows average.docxThe fiscal 2012 financial statements of Barney Services shows average.docx
The fiscal 2012 financial statements of Barney Services shows average.docxcarold11
 
The equity sections from Atticus Group The equity sections from.docx
The equity sections from Atticus Group        The equity sections from.docxThe equity sections from Atticus Group        The equity sections from.docx
The equity sections from Atticus Group The equity sections from.docxcarold11
 
The executive officers of Rouse Corporation have a performance-based c.docx
The executive officers of Rouse Corporation have a performance-based c.docxThe executive officers of Rouse Corporation have a performance-based c.docx
The executive officers of Rouse Corporation have a performance-based c.docxcarold11
 
The Federal Reserve had to resort to non-standard methods to try to st.docx
The Federal Reserve had to resort to non-standard methods to try to st.docxThe Federal Reserve had to resort to non-standard methods to try to st.docx
The Federal Reserve had to resort to non-standard methods to try to st.docxcarold11
 
The EU recently admitted the Eastern European countries- How do you as.docx
The EU recently admitted the Eastern European countries- How do you as.docxThe EU recently admitted the Eastern European countries- How do you as.docx
The EU recently admitted the Eastern European countries- How do you as.docxcarold11
 
The Esposito Import Company had 1 million shares of common stock outst.docx
The Esposito Import Company had 1 million shares of common stock outst.docxThe Esposito Import Company had 1 million shares of common stock outst.docx
The Esposito Import Company had 1 million shares of common stock outst.docxcarold11
 
The energy levels of electrons are related to their- a) Position on t.docx
The energy levels of electrons are related to their-  a) Position on t.docxThe energy levels of electrons are related to their-  a) Position on t.docx
The energy levels of electrons are related to their- a) Position on t.docxcarold11
 
The Electron in a Hydrogen Atom transforms from its n-1 state to its n.docx
The Electron in a Hydrogen Atom transforms from its n-1 state to its n.docxThe Electron in a Hydrogen Atom transforms from its n-1 state to its n.docx
The Electron in a Hydrogen Atom transforms from its n-1 state to its n.docxcarold11
 
The Fed follows the theory of bureaucratic behavior in what sense-.docx
The Fed follows the theory of bureaucratic behavior in what sense-.docxThe Fed follows the theory of bureaucratic behavior in what sense-.docx
The Fed follows the theory of bureaucratic behavior in what sense-.docxcarold11
 
Pay structures Union contracts Wage and price contracts Levels of reve.docx
Pay structures Union contracts Wage and price contracts Levels of reve.docxPay structures Union contracts Wage and price contracts Levels of reve.docx
Pay structures Union contracts Wage and price contracts Levels of reve.docxcarold11
 
Pat ts oints Give all answers to the corret number of significant figu.docx
Pat ts oints Give all answers to the corret number of significant figu.docxPat ts oints Give all answers to the corret number of significant figu.docx
Pat ts oints Give all answers to the corret number of significant figu.docxcarold11
 

Mehr von carold11 (20)

The Financial Management Decision Process What are the three types of.docx
The Financial Management Decision Process What are the three types of.docxThe Financial Management Decision Process What are the three types of.docx
The Financial Management Decision Process What are the three types of.docx
 
The Federal Reserve attempts to keep prices stable and unemployment lo.docx
The Federal Reserve attempts to keep prices stable and unemployment lo.docxThe Federal Reserve attempts to keep prices stable and unemployment lo.docx
The Federal Reserve attempts to keep prices stable and unemployment lo.docx
 
The following class stores a list of integer values and contains a met.docx
The following class stores a list of integer values and contains a met.docxThe following class stores a list of integer values and contains a met.docx
The following class stores a list of integer values and contains a met.docx
 
The following accounts were taken from ABC CompanySolutionCalculation.docx
The following accounts were taken from ABC CompanySolutionCalculation.docxThe following accounts were taken from ABC CompanySolutionCalculation.docx
The following accounts were taken from ABC CompanySolutionCalculation.docx
 
The following are key terms in Chapter 14 that relate to regulatory an.docx
The following are key terms in Chapter 14 that relate to regulatory an.docxThe following are key terms in Chapter 14 that relate to regulatory an.docx
The following are key terms in Chapter 14 that relate to regulatory an.docx
 
The following account balances relate to the stockholders equity accou.docx
The following account balances relate to the stockholders equity accou.docxThe following account balances relate to the stockholders equity accou.docx
The following account balances relate to the stockholders equity accou.docx
 
The following accounts were taken from ABC CompanySolutionCalculation (3).docx
The following accounts were taken from ABC CompanySolutionCalculation (3).docxThe following accounts were taken from ABC CompanySolutionCalculation (3).docx
The following accounts were taken from ABC CompanySolutionCalculation (3).docx
 
The following accounts were taken from ABC CompanySolutionCalculation (2).docx
The following accounts were taken from ABC CompanySolutionCalculation (2).docxThe following accounts were taken from ABC CompanySolutionCalculation (2).docx
The following accounts were taken from ABC CompanySolutionCalculation (2).docx
 
The following accounts were taken from ABC CompanySolutionCalculation (1).docx
The following accounts were taken from ABC CompanySolutionCalculation (1).docxThe following accounts were taken from ABC CompanySolutionCalculation (1).docx
The following accounts were taken from ABC CompanySolutionCalculation (1).docx
 
The fiscal 2012 financial statements of Barney Services shows average.docx
The fiscal 2012 financial statements of Barney Services shows average.docxThe fiscal 2012 financial statements of Barney Services shows average.docx
The fiscal 2012 financial statements of Barney Services shows average.docx
 
The equity sections from Atticus Group The equity sections from.docx
The equity sections from Atticus Group        The equity sections from.docxThe equity sections from Atticus Group        The equity sections from.docx
The equity sections from Atticus Group The equity sections from.docx
 
The executive officers of Rouse Corporation have a performance-based c.docx
The executive officers of Rouse Corporation have a performance-based c.docxThe executive officers of Rouse Corporation have a performance-based c.docx
The executive officers of Rouse Corporation have a performance-based c.docx
 
The Federal Reserve had to resort to non-standard methods to try to st.docx
The Federal Reserve had to resort to non-standard methods to try to st.docxThe Federal Reserve had to resort to non-standard methods to try to st.docx
The Federal Reserve had to resort to non-standard methods to try to st.docx
 
The EU recently admitted the Eastern European countries- How do you as.docx
The EU recently admitted the Eastern European countries- How do you as.docxThe EU recently admitted the Eastern European countries- How do you as.docx
The EU recently admitted the Eastern European countries- How do you as.docx
 
The Esposito Import Company had 1 million shares of common stock outst.docx
The Esposito Import Company had 1 million shares of common stock outst.docxThe Esposito Import Company had 1 million shares of common stock outst.docx
The Esposito Import Company had 1 million shares of common stock outst.docx
 
The energy levels of electrons are related to their- a) Position on t.docx
The energy levels of electrons are related to their-  a) Position on t.docxThe energy levels of electrons are related to their-  a) Position on t.docx
The energy levels of electrons are related to their- a) Position on t.docx
 
The Electron in a Hydrogen Atom transforms from its n-1 state to its n.docx
The Electron in a Hydrogen Atom transforms from its n-1 state to its n.docxThe Electron in a Hydrogen Atom transforms from its n-1 state to its n.docx
The Electron in a Hydrogen Atom transforms from its n-1 state to its n.docx
 
The Fed follows the theory of bureaucratic behavior in what sense-.docx
The Fed follows the theory of bureaucratic behavior in what sense-.docxThe Fed follows the theory of bureaucratic behavior in what sense-.docx
The Fed follows the theory of bureaucratic behavior in what sense-.docx
 
Pay structures Union contracts Wage and price contracts Levels of reve.docx
Pay structures Union contracts Wage and price contracts Levels of reve.docxPay structures Union contracts Wage and price contracts Levels of reve.docx
Pay structures Union contracts Wage and price contracts Levels of reve.docx
 
Pat ts oints Give all answers to the corret number of significant figu.docx
Pat ts oints Give all answers to the corret number of significant figu.docxPat ts oints Give all answers to the corret number of significant figu.docx
Pat ts oints Give all answers to the corret number of significant figu.docx
 

Kürzlich hochgeladen

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
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 functionsKarakKing
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
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.christianmathematics
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
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.pptxheathfieldcps1
 
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.MaryamAhmad92
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
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).pptxEsquimalt MFRC
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
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.pdfNirmal Dwivedi
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 

Kürzlich hochgeladen (20)

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
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
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
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.
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
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.
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
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
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
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
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
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
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 

The enqueue operation on the Queue ADT adds a new item to the back of (1).docx

  • 1. The enqueue operation on the Queue ADT adds a new item to the back of the queue where the dequeue operation removes and returns the item from the front of the queue. Now consider an initially empty queue and find the final output for the following sequence of queue operations: enqueue(7); enqueue(9); enqueue(1); dequeue(); enqueue(8); dequeue(); dequeue(); enqueue(6); enqueue(3); dequeue(); enqueue(2); enqueue(1); dequeue(); Solution import java.util.*; java.io.*; java.lang.*; class Queue { private ArrayList list; public Queue() { list = new ArrayList(); } public void enqueue(Object object) { if(list.isFull()) System.out.println(“Queue overflowed―); else list.add(object); }
  • 2. public Object dequeue() { if(list.isEmpty()) System.out.println(“Queue underflow―); else return list.remove(list.size() - 1); } public boolean isEmpty() { return list.isEmpty(); } public Object front() { return list.get(list.size() - 1); } public Object back() { return list.get(index); } public void clear() { list.clear(); } } class QSample { public static void main(String args[]) throws Exception { Queue q=new Queue();   while(true) { System.out.println(" t QUEUE ");