0% found this document useful (0 votes)
15 views7 pages

Stack and Queue Data Structures Explained

The document provides an overview of stacks, a Last-In-First-Out (LIFO) data structure where items are accessed from the top. It explains key operations such as PUSH (inserting an item) and POP (removing an item), as well as terms like Peek, Overflow, and Underflow. Additionally, it includes details on implementing stacks in Python with functions for checking emptiness, adding, removing, and displaying items.

Uploaded by

aditya1401sharma
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)
15 views7 pages

Stack and Queue Data Structures Explained

The document provides an overview of stacks, a Last-In-First-Out (LIFO) data structure where items are accessed from the top. It explains key operations such as PUSH (inserting an item) and POP (removing an item), as well as terms like Peek, Overflow, and Underflow. Additionally, it includes details on implementing stacks in Python with functions for checking emptiness, adding, removing, and displaying items.

Uploaded by

aditya1401sharma
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

DATA STRUCTURE - II

Stack and Queues


STACK
A stack is a collection of data items that can be
accessed at only one end, called top.
Items can be inserted and deleted in a stack only
at the top.
The last item inserted in a stack is the first one
to be deleted.
Therefore, a stack is called a Last-In-First-Out
(LIFO) data structure.
2 mains operations on Stack is PUSH & POP
PUSH means inserting new item at top and POP
means deleting item from top.
OTHER STACK TERM
 Peek : getting the most recent value of stack i.e
value at TOP

 OverFlow : a situation when we are Pushing item


in Stack that is full.

 Underflow : a situation when we are Popping


item from empty stack
IMPLEMENTING STACK IN PYTHON
This function will
check Stack is
empty or not

This function will


add new item in
Stack, here setting
top is mandatory

This function is used


to remove item from
stack, also perform
checks before deletion
IMPLEMENTING STACK IN PYTHON
This function will
return the top
most item from the
stack

This function will


display stack items
IMPLEMENTING STACK IN PYTHON

Displaying menu
to user to interact
IMPLEMENTING STACK IN PYTHON

You might also like