0% found this document useful (0 votes)
14 views

Introduction To Data Structures and Algorithms - Lecture 5

Uploaded by

Tasneem Kubra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Introduction To Data Structures and Algorithms - Lecture 5

Uploaded by

Tasneem Kubra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Lecture 05

Stack and Queue


3.8 Stack
Stack is a linear data structure which follows a particular order in which the operations are
performed. The order may be LIFO (Last in First Out) or FILO (First in Last Out).

Figure 3.10 inserting and deleting elements from stack

3.8.1 Example of stack

Figure 3.11(a) stack implementation

1
Figure 3.11(b) stack implementation

2
3.9 Queue
A Queue is a linear structure which follows a particular order in which the operations are
performed. The order is First in First Out (FIFO). A good example of a queue is any queue of
consumers for a resource where the consumer that came first is served first. The difference
between stacks and queues is in removing. In a stack we remove the item the most recently
added; in a queue, we remove the item the least recently added.

Figure 3.12 Queue

3.9.1 Example of queue

Figure 3.13 (a) implementation of queue

3
Figure 3.13 (b) implementation of queue

You might also like