SlideShare uma empresa Scribd logo
1 de 20
Lists, Queues,
Stacks
CST200 – Week 5: Array based Implementation

Instructor: Andreea Molnar
Outline
• Lists
• Queues
• Stacks
List
A sequence of items that has at least the
functionality below:

• Accessing an item at a given position
• Adding an item at a given position
• Removing an item
• Determining the number of items
Stack
A sequence of items in which:

•
•

An item can be inserted only to the top
Only the top item can be
accessed/removed

In a stack items are inserted and removed
according to the last-in first-out (LIFO)
principle.
Stack
Functionality:

•
•
•
•
•

push: insert an item to the top of the stack
pop: remove the item at the top of the stack

peek: get the item at the top of the stack
isEmpty: assess if the stack is empty

isFull: assess if the stack is full
Stack
Assuming that one has an object myStack:

myStack.push (25)

25

mySta
ck
Stack
Assuming that one has an object myStack:

myStack.push (25)
myStack.push (10)

10

25

mySta
ck
Stack
Assuming that one has an object myStack:

myStack.push (25)

myStack.push (10)

10
25

mySta
ck

int topValue = myStack.pop ()

10

topVa
lue
Stack
Assuming that one has an object myStack:
myStack.push (25)
myStack.push (10)

int topValue = myStack.pop ()

5
25

mySta
ck

myStack.push (5)

10

topVa
lue
Stack
Assuming that one has an object myStack
myStack.push (25)
myStack.push (10)

5
25

mySta
ck

int topValue = myStack.pop ()
myStack.push (5)

10

topVa
lue
Stack
Assuming that one has an object myStack:
myStack.push (25)
myStack.push (10)
int topValue = myStack.pop ()
myStack.push (5)
myStack.push (20)

20
5
25
10

mySta
ck

topVa
lue
Stack
Assuming that one has an object myStack:
myStack.push (25)

myStack.push (10)
int topValue = myStack.pop ()

myStack.push (5)
myStack.push (20)
topValue = myStack.pop ()

20
5
25
20

mySta
ck

topVa
lue
Queue
A sequence of items in which the first
element inserted is the first one to be
removed.
In a queue elements are inserted and
removed based on the the first-in first-out
(FIFO) principle.
Queue
Functionality:

•
•
•

enqueue: add an item to the back of the queue

dequeue: remove the front item
getFront: get the front item
Queue
Assuming that one has an object myQueue:

myQueue.enque (25)

25

myQue
ue
Queue
Assuming that one has an object myQueue:

myQueue.enque (25)
int value = myQueue.deque ()

25

25

myQue
ue
value
Queue
Assuming that one has an object myQueue:

myQueue.enque (25)
int value = myQueue.deque ()

20

myQueue.enque (20)

25

myQue
ue
value
Queue
Assuming that one has an object myQueue:

myQueue.enque (25)
int value = myQueue.deque ()

myQueue.enque (20)

20

5

myQue
ue

myQueue.enque (5)

25

value
Queue
Assuming that one has an object myQueue:
myQueue.enque (25)
int value = myQueue.deque ()
myQueue.enque (20)

20

5

myQueue.enque (5)
value = myQueue.deque ()

20

myQue
ue
value
Summary
•
•
•

A list is sequence of items that allows to access, add
and remove an arbitrary element and determine the
numbers of items (length/size of the list).
A stack is a data structure in which an item can be
added, accessed or removed only from the top.
A queue is a data structure in which the first element
added is the first one to be accessed/removed.

Mais conteúdo relacionado

Semelhante a Lists, queues and stacks

Semelhante a Lists, queues and stacks (20)

Queues.ppt
Queues.pptQueues.ppt
Queues.ppt
 
Queues.ppt
Queues.pptQueues.ppt
Queues.ppt
 
Queues.ppt
Queues.pptQueues.ppt
Queues.ppt
 
QueuYUGHIJLK;KJHGFCFYUGIHOJUHYGHJIOIHGes.ppt
QueuYUGHIJLK;KJHGFCFYUGIHOJUHYGHJIOIHGes.pptQueuYUGHIJLK;KJHGFCFYUGIHOJUHYGHJIOIHGes.ppt
QueuYUGHIJLK;KJHGFCFYUGIHOJUHYGHJIOIHGes.ppt
 
stack coding.pptx
stack coding.pptxstack coding.pptx
stack coding.pptx
 
Stacks, Queues, Deques
Stacks, Queues, DequesStacks, Queues, Deques
Stacks, Queues, Deques
 
Queues.ppt
Queues.pptQueues.ppt
Queues.ppt
 
Stacks.ppt
Stacks.pptStacks.ppt
Stacks.ppt
 
Stacks.ppt
Stacks.pptStacks.ppt
Stacks.ppt
 
Stack and Queue.pptx university exam preparation
Stack and Queue.pptx university exam preparationStack and Queue.pptx university exam preparation
Stack and Queue.pptx university exam preparation
 
stack presentation
stack presentationstack presentation
stack presentation
 
Queues.ppt
Queues.pptQueues.ppt
Queues.ppt
 
CEN 235 4. Abstract Data Types - Queue and Stack.pdf
CEN 235 4. Abstract Data Types - Queue and Stack.pdfCEN 235 4. Abstract Data Types - Queue and Stack.pdf
CEN 235 4. Abstract Data Types - Queue and Stack.pdf
 
GAC DS Priority Queue Presentation 2022.ppt
GAC DS Priority Queue Presentation 2022.pptGAC DS Priority Queue Presentation 2022.ppt
GAC DS Priority Queue Presentation 2022.ppt
 
Queue
QueueQueue
Queue
 
Lecture#5 - Stack ADT.pptx
Lecture#5 - Stack ADT.pptxLecture#5 - Stack ADT.pptx
Lecture#5 - Stack ADT.pptx
 
Bca ii dfs u-2 linklist,stack,queue
Bca ii  dfs u-2 linklist,stack,queueBca ii  dfs u-2 linklist,stack,queue
Bca ii dfs u-2 linklist,stack,queue
 
2.1 STACK & QUEUE ADTS
2.1 STACK & QUEUE ADTS2.1 STACK & QUEUE ADTS
2.1 STACK & QUEUE ADTS
 
Queues & ITS TYPES
Queues & ITS TYPESQueues & ITS TYPES
Queues & ITS TYPES
 
Bsc cs ii dfs u-2 linklist,stack,queue
Bsc cs ii  dfs u-2 linklist,stack,queueBsc cs ii  dfs u-2 linklist,stack,queue
Bsc cs ii dfs u-2 linklist,stack,queue
 

Mais de ASU Online

Midterm common mistakes
Midterm common mistakesMidterm common mistakes
Midterm common mistakesASU Online
 
Classes revision
Classes revisionClasses revision
Classes revisionASU Online
 
For loop java 2
For loop java 2For loop java 2
For loop java 2ASU Online
 
Reading and writting v2
Reading and writting v2Reading and writting v2
Reading and writting v2ASU Online
 
Common errors v2
Common errors v2Common errors v2
Common errors v2ASU Online
 
Common missunderestandings
Common missunderestandingsCommon missunderestandings
Common missunderestandingsASU Online
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to javaASU Online
 
Lecture 14 tourism in europe
Lecture 14   tourism in europeLecture 14   tourism in europe
Lecture 14 tourism in europeASU Online
 
Lecture 13 tourism in the south pacific
Lecture 13   tourism in the south pacificLecture 13   tourism in the south pacific
Lecture 13 tourism in the south pacificASU Online
 
Lecture 12 tourism in australia and new zealand
Lecture 12   tourism in australia and new zealandLecture 12   tourism in australia and new zealand
Lecture 12 tourism in australia and new zealandASU Online
 
Lecture 11 tourism in east asia
Lecture 11   tourism in east asiaLecture 11   tourism in east asia
Lecture 11 tourism in east asiaASU Online
 
Lecture 9 tourism in south asia
Lecture 9   tourism in south asiaLecture 9   tourism in south asia
Lecture 9 tourism in south asiaASU Online
 
Lecture 9 tourism in south asia-1
Lecture 9   tourism in south asia-1Lecture 9   tourism in south asia-1
Lecture 9 tourism in south asia-1ASU Online
 
Lecture 8 tourism in central asia
Lecture 8   tourism in central asiaLecture 8   tourism in central asia
Lecture 8 tourism in central asiaASU Online
 
Lecture 7 tourism in the middle east and north africa
Lecture 7   tourism in the middle east and north africaLecture 7   tourism in the middle east and north africa
Lecture 7 tourism in the middle east and north africaASU Online
 
Lecture 6 tourism in sub-saharan africa
Lecture 6   tourism in sub-saharan africaLecture 6   tourism in sub-saharan africa
Lecture 6 tourism in sub-saharan africaASU Online
 
Lecture 5 tourism in latin america
Lecture 5   tourism in latin americaLecture 5   tourism in latin america
Lecture 5 tourism in latin americaASU Online
 
Lecture 4 tourism in the caribbean
Lecture 4   tourism in the caribbeanLecture 4   tourism in the caribbean
Lecture 4 tourism in the caribbeanASU Online
 
Lecture 3 political context of international tourism
Lecture 3   political context of international tourismLecture 3   political context of international tourism
Lecture 3 political context of international tourismASU Online
 
Lecture 2 impacts of tourism global dist
Lecture 2 impacts of tourism   global distLecture 2 impacts of tourism   global dist
Lecture 2 impacts of tourism global distASU Online
 

Mais de ASU Online (20)

Midterm common mistakes
Midterm common mistakesMidterm common mistakes
Midterm common mistakes
 
Classes revision
Classes revisionClasses revision
Classes revision
 
For loop java 2
For loop java 2For loop java 2
For loop java 2
 
Reading and writting v2
Reading and writting v2Reading and writting v2
Reading and writting v2
 
Common errors v2
Common errors v2Common errors v2
Common errors v2
 
Common missunderestandings
Common missunderestandingsCommon missunderestandings
Common missunderestandings
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Lecture 14 tourism in europe
Lecture 14   tourism in europeLecture 14   tourism in europe
Lecture 14 tourism in europe
 
Lecture 13 tourism in the south pacific
Lecture 13   tourism in the south pacificLecture 13   tourism in the south pacific
Lecture 13 tourism in the south pacific
 
Lecture 12 tourism in australia and new zealand
Lecture 12   tourism in australia and new zealandLecture 12   tourism in australia and new zealand
Lecture 12 tourism in australia and new zealand
 
Lecture 11 tourism in east asia
Lecture 11   tourism in east asiaLecture 11   tourism in east asia
Lecture 11 tourism in east asia
 
Lecture 9 tourism in south asia
Lecture 9   tourism in south asiaLecture 9   tourism in south asia
Lecture 9 tourism in south asia
 
Lecture 9 tourism in south asia-1
Lecture 9   tourism in south asia-1Lecture 9   tourism in south asia-1
Lecture 9 tourism in south asia-1
 
Lecture 8 tourism in central asia
Lecture 8   tourism in central asiaLecture 8   tourism in central asia
Lecture 8 tourism in central asia
 
Lecture 7 tourism in the middle east and north africa
Lecture 7   tourism in the middle east and north africaLecture 7   tourism in the middle east and north africa
Lecture 7 tourism in the middle east and north africa
 
Lecture 6 tourism in sub-saharan africa
Lecture 6   tourism in sub-saharan africaLecture 6   tourism in sub-saharan africa
Lecture 6 tourism in sub-saharan africa
 
Lecture 5 tourism in latin america
Lecture 5   tourism in latin americaLecture 5   tourism in latin america
Lecture 5 tourism in latin america
 
Lecture 4 tourism in the caribbean
Lecture 4   tourism in the caribbeanLecture 4   tourism in the caribbean
Lecture 4 tourism in the caribbean
 
Lecture 3 political context of international tourism
Lecture 3   political context of international tourismLecture 3   political context of international tourism
Lecture 3 political context of international tourism
 
Lecture 2 impacts of tourism global dist
Lecture 2 impacts of tourism   global distLecture 2 impacts of tourism   global dist
Lecture 2 impacts of tourism global dist
 

Último

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 

Último (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 

Lists, queues and stacks

  • 1. Lists, Queues, Stacks CST200 – Week 5: Array based Implementation Instructor: Andreea Molnar
  • 3. List A sequence of items that has at least the functionality below: • Accessing an item at a given position • Adding an item at a given position • Removing an item • Determining the number of items
  • 4. Stack A sequence of items in which: • • An item can be inserted only to the top Only the top item can be accessed/removed In a stack items are inserted and removed according to the last-in first-out (LIFO) principle.
  • 5. Stack Functionality: • • • • • push: insert an item to the top of the stack pop: remove the item at the top of the stack peek: get the item at the top of the stack isEmpty: assess if the stack is empty isFull: assess if the stack is full
  • 6. Stack Assuming that one has an object myStack: myStack.push (25) 25 mySta ck
  • 7. Stack Assuming that one has an object myStack: myStack.push (25) myStack.push (10) 10 25 mySta ck
  • 8. Stack Assuming that one has an object myStack: myStack.push (25) myStack.push (10) 10 25 mySta ck int topValue = myStack.pop () 10 topVa lue
  • 9. Stack Assuming that one has an object myStack: myStack.push (25) myStack.push (10) int topValue = myStack.pop () 5 25 mySta ck myStack.push (5) 10 topVa lue
  • 10. Stack Assuming that one has an object myStack myStack.push (25) myStack.push (10) 5 25 mySta ck int topValue = myStack.pop () myStack.push (5) 10 topVa lue
  • 11. Stack Assuming that one has an object myStack: myStack.push (25) myStack.push (10) int topValue = myStack.pop () myStack.push (5) myStack.push (20) 20 5 25 10 mySta ck topVa lue
  • 12. Stack Assuming that one has an object myStack: myStack.push (25) myStack.push (10) int topValue = myStack.pop () myStack.push (5) myStack.push (20) topValue = myStack.pop () 20 5 25 20 mySta ck topVa lue
  • 13. Queue A sequence of items in which the first element inserted is the first one to be removed. In a queue elements are inserted and removed based on the the first-in first-out (FIFO) principle.
  • 14. Queue Functionality: • • • enqueue: add an item to the back of the queue dequeue: remove the front item getFront: get the front item
  • 15. Queue Assuming that one has an object myQueue: myQueue.enque (25) 25 myQue ue
  • 16. Queue Assuming that one has an object myQueue: myQueue.enque (25) int value = myQueue.deque () 25 25 myQue ue value
  • 17. Queue Assuming that one has an object myQueue: myQueue.enque (25) int value = myQueue.deque () 20 myQueue.enque (20) 25 myQue ue value
  • 18. Queue Assuming that one has an object myQueue: myQueue.enque (25) int value = myQueue.deque () myQueue.enque (20) 20 5 myQue ue myQueue.enque (5) 25 value
  • 19. Queue Assuming that one has an object myQueue: myQueue.enque (25) int value = myQueue.deque () myQueue.enque (20) 20 5 myQueue.enque (5) value = myQueue.deque () 20 myQue ue value
  • 20. Summary • • • A list is sequence of items that allows to access, add and remove an arbitrary element and determine the numbers of items (length/size of the list). A stack is a data structure in which an item can be added, accessed or removed only from the top. A queue is a data structure in which the first element added is the first one to be accessed/removed.