0% found this document useful (0 votes)
22 views3 pages

Stack and Queue

Uploaded by

adnanvista
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)
22 views3 pages

Stack and Queue

Uploaded by

adnanvista
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

Supported documents for week 3

assignments.
Stack
A Stack is a non-primitive linear data structure. It is an ordered list in which the addition of a new
data item and deletion of an already existing data item can be done from only one end, known as
top of the stack.

The last added element will be the first to be removed from the Stack. That is the reason why
stack is also called Last In First Out (LIFO) type of data structure.

Basic operations on Stack


Push

The process of adding a new element to the top of the Stack is called the Push operation.

Pop

The process of deleting an existing element from the top of the Stack is called the Pop operation.
It returns the deleted value.

Traverse/Display

The process of accessing or reading each element from top to bottom in Stack is called the
Traverse operation.
Applications of Stack
Reverse the string
Evaluate Expression
Undo/Redo Operation
Backtracking
Depth First Search(DFS) in Graph(Will be discussed in Week-4)

Implementation of Stack in Python


Using a list
Using a Linked list

Queue
The Queue is a non-primitive linear data structure. It is an ordered collection of elements in which
new elements are added at one end called the Back end, and the existing element is deleted
from the other end called the Front end.

A Queue is logically called a First In First Out (FIFO) type of data structure.

Basic operations on Queue


Enqueue

The process of adding a new element at the Back end of Queue is called the Enqueue operation.

Dequeue

The process of deleting an existing element from the Front of the Queue is called the Dequeue
operation. It returns the deleted value.
Traverse/Display

The process of accessing or reading each element from Front to Back of the Queue is called the
Traverse operation.

Applications of Queue
Spooling in printers
Job Scheduling in OS
Waiting list application
Breadth First Search(BFS) in Graph(Will be discussed in Week-4)

Implementation of the Queue in python


Using a list
Using a Linked list

You might also like