0% found this document useful (0 votes)
33 views11 pages

Stack 1

The document discusses stack as an abstract data type and linear data structure that follows LIFO order, with operations like push to add an item and pop to remove the top item; it also presents examples of stack applications in balancing symbols, conversion between infix/postfix notation, and features of web browsers and editors. Key aspects of stacks covered are their bounded capacity, push and pop operations, and use in algorithms and applications that require LIFO data organization.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views11 pages

Stack 1

The document discusses stack as an abstract data type and linear data structure that follows LIFO order, with operations like push to add an item and pop to remove the top item; it also presents examples of stack applications in balancing symbols, conversion between infix/postfix notation, and features of web browsers and editors. Key aspects of stacks covered are their bounded capacity, push and pop operations, and use in algorithms and applications that require LIFO data organization.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Lecture

By: Saeed Ahmed


Stack Data Structure:
Stack is a linear data structure which operates in a LIFO(Last In First Out) or FILO (First In
Last Out) pattern.

 It is named stack as it behaves like a real-world stack, for example – a deck of cards or a
pile of plates, etc.
 Stack is an abstract data type with a bounded (predefined) capacity.
 It is a simple data structure that allows adding and removing elements in a particular order.
 The order may be LIFO(Last In First Out) or FILO(First In Last Out).
Stack Data Structure:
Stack is a liner data structure which operates in a LIFO(Last In First Out) and
FILO(First In Last Out) pattern
Stack size = 3
Top =
Index = 0 , 1 , 2
Size = 1, 2 , 3
Items are add on top of stack.
This is known as PUSH operation.

Items are removed from the top of


The stack. This is known as POP
operation
Stack Data Structure Operations:
 push()
place an item onto the stack. If there is no place for new item, stack is in overflow state.

 pop()
Return the item at the top of the stack and then remove it. if pop is called when stack is empty,
it is in an underflow state.

 isEmpty()
Tells if the stack is empty or not.

 Isfull()
Tells if the stack is full or not.
Stack Data Structure Operations:

 Peek()
Access the item at the i position

 Count()
Get the number of items in the stack

 Change()
Change the item at the i position

 Display()
Display all the items in the stack.
Stack Data Structure Operations:

 Peek()
Access the item at the i position

 Count()
Get the number of items in the stack

 Change()
Change the item at the i position

 Display()
Display all the items in the stack.
Some Application Stack Data Structure:
 Balancing of symbols

 infix to Postfix/Prefix conversion

 Redo-undo features at many places like editors, photoshop

 Forward and backward feature in web browsers

 Used in many algorithms like Tower of Hanoi.


Abstract Data Types in Data Structures.:
 Data Structures: In computer science ,a data structure is a
 data organization, management and storage form a that enables efficient access and
modification.

2. Ways of looking of Data Structure.

 Mathematical/Logical/Abstract Models/View
 Implementation.

 ADTs are entities that are definitions of data and operations but do not have
implementation details.
Abstract Data Types in Data Structures.:
 Data Structures: In computer science ,a data structure is a
 data organization, management and storage form a that enables efficient access and
modification.

2. Ways of looking of Data Structure.

 Mathematical/Logical/Abstract Models/View
 Implementation.

 ADTs are entities that are definitions of data and operations but do not have
implementation details.
Abstract Data Types in Data Structures.:
Real World Example: Smart Phone

Abstract/logical View Implementation


4- GB RAM class Smartphone
Snapdragon 2.2GHz processor {
5.5 inch LCD screen private"
Dual Camera int ramsize
Android 8.0 string processorName
float screensize
call() int cameracount
text() String android version
photo() call()
video() text()
photo()
video()
}
Abstract Data Types in Data Structures.:
Data Structure Example: Array Example

Value of Array
1 2 3 4 5 6
0 1 2 3 4 5
Index of Array

Abstract/logical View Implementation


Store a set of elements of int Int arr[5] = {1,2,3,4,5,6}
Read element by index Cout << arr[1]
Modify element by index Arr[2] = 210
Perform sorting

You might also like