SlideShare une entreprise Scribd logo
1  sur  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.

Contenu connexe

Similaire à Lists, queues and stacks

Similaire à 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
 

Plus 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
 

Plus 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
 

Dernier

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 

Dernier (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

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.