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

Stack Data Structure: Stack Introduction Implementation in Python

This document discusses stacks, a linear data structure that follows LIFO (Last In First Out) order. It describes the basic stack operations of push, pop, peek, and isEmpty. It explains that stacks can be implemented using arrays or linked lists. Finally, it provides examples of how stacks are used in computer science problems like expression evaluation and memory management as well as real-life applications like browsing history and stacks of books.

Uploaded by

Kanchan jain
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)
44 views

Stack Data Structure: Stack Introduction Implementation in Python

This document discusses stacks, a linear data structure that follows LIFO (Last In First Out) order. It describes the basic stack operations of push, pop, peek, and isEmpty. It explains that stacks can be implemented using arrays or linked lists. Finally, it provides examples of how stacks are used in computer science problems like expression evaluation and memory management as well as real-life applications like browsing history and stacks of books.

Uploaded by

Kanchan jain
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/ 7

STACK DATA STRUCTURE

STACK INTRODUCTION IMPLEMENTATION IN PYTHON

BY-KANCHAN JAIN
SHE ARISE PYTHON BATCH-1
WHAT IS 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).
*Top is that element which has been
inserted at last and can be retrieved first.
We can't access any element except top.
* It is useful when we want to solve the
problem of o(n^2) in o(n).
OPERATIONS PERFORM
ON STACKS
Mainly the following four basic operations
are performed in the stack:

Push: Adds an item in the stack. If the


stack is full, then it is said to be an
Overflow condition.In order to insert
any element inside the stack it is necessary
to check overflow condition.

•Pop: Removes an item from the stack.


The items are popped in the reversed order
in which they are pushed. If the stack is
empty, then it is said to be an Underflow
condition.before delete operation
perform on stack underflow condition
should be checked first

•Peek or Top: Returns top element of


stack.

•isEmpty: Returns true if stack is empty,


else false.
IMPLEMENTATION OF
STACK

There are two ways to implement a


stack:

1.Using array: when we know the size of


stack.
2.Using linked list: when we does not
now the size of stack.
IMPLEMENTATION OF STACK USING LIST IN
PYTHON

CODE IN PYTHON OUTPUT OF CODE


APPLICATION OF
STACKS
1.COMPUTER SCIENCE APPLICATION:
•Stacks can be used for expression
evaluation.
•Stacks can be used to check parenthesis
matching in an expression.
•Stacks can be used for Conversion from one
form of expression to another.
•Stacks can be used for Memory
Management.
•Stack data structures are used in
backtracking problems
2. REAL LIFE APPLICATION:
.Stack concept are used in browsing history.
.Piles of books
.Stack of trays
THANKS YOU

You might also like