This document discusses stacks and their applications. It begins with an introduction to stacks, describing them as data structures that follow the last-in, first-out (LIFO) principle. It then outlines stack operations like push, pop, top, and describes how stacks can be implemented using arrays or linked lists. Several applications of stacks are mentioned, including parenthesis matching, expression evaluation in postfix notation, handling function calls and returns, and undo sequences. Examples are provided to illustrate postfix notation, converting infix to postfix expressions, and evaluating postfix expressions using a stack.
Stacks and Queues: Introduction to stacks
applications of stacks
implementation and comparison of stack implementations.
Introduction to queues
applications of queues and implementations
Priority Queues and applications
Stack is a collection based on the principle of adding elements and retrieving them in the opposite order
What is STACK?
Stack Operations
Applications
Built-in Stack
Downloadable Resources
queue datastructure made easy and datastructure explained in java. visit http://technoexplore.blogspot.com and http://hotjobstuff.blogspot.com for some other important presentations.
Stacks and Queues: Introduction to stacks
applications of stacks
implementation and comparison of stack implementations.
Introduction to queues
applications of queues and implementations
Priority Queues and applications
Stack is a collection based on the principle of adding elements and retrieving them in the opposite order
What is STACK?
Stack Operations
Applications
Built-in Stack
Downloadable Resources
queue datastructure made easy and datastructure explained in java. visit http://technoexplore.blogspot.com and http://hotjobstuff.blogspot.com for some other important presentations.
Concept of stack ,stack of aaray stack by linked list , application of stac...muskankumari7360
A stack is a linear data structure that follows the Last In, First Out (LIFO) principle, meaning the last element added to the stack is the first one to be removed. Elements can only be added or removed from the top of the stack. This structure resembles a stack of plates, where you can only add or remove plates from the top of the pile. Stacks are commonly used in computer science for tasks such as function call management, expression evaluation, and undo functionality in applications.
Application of Stack For Expression Evaluation by Prakash Zodge DSY 41.pptxPrakash Zodge
In short...The stack organization is very effective in evaluating arithmetic expressions. Expressions are usually represented in what is known as Infix notation, in which each operator is written between two operands (i.e., A + B)....
Stack and its Applications : Data Structures ADTSoumen Santra
Stack is an Abstract Data Type (ADT), Last in First out (LIFO) concept.
Features of Stack: Abstract Data Type (ADT)
C implementations of Stack's Functions like push(), pop(), isEmpty(), isOverflow(), peep()
Stack Applications like Tower of Hanoi, Infix to Postfix Conversion, Postfix Evaluation, Parenthesis Checking etc.
Diagramatic Representation of Tower of Hanoi, Infix to Postfix Conversion & Postfix Evaluation
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
The Art Pastor's Guide to Sabbath | Steve ThomasonSteve Thomason
What is the purpose of the Sabbath Law in the Torah. It is interesting to compare how the context of the law shifts from Exodus to Deuteronomy. Who gets to rest, and why?
How to Create Map Views in the Odoo 17 ERPCeline George
The map views are useful for providing a geographical representation of data. They allow users to visualize and analyze the data in a more intuitive manner.
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
2024.06.01 Introducing a competency framework for languag learning materials ...
Chapter 6 ds
1. Chapter 6
Stacks
Dr. Muhammad Hanif Durad
Department of Computer and Information Sciences
Pakistan Institute Engineering and Applied Sciences
hanif@pieas.edu.pk
Some slides have bee adapted with thanks from some other lectures
available on Internet. It made my life easier, as life is always
miserable at PIEAS (Sir Muhammad Yusaf Kakakhil )
2. Dr. Hanif Durad 2
Lecture Outline
Introduction
Stack
Stack operations
Implementation of Stacks
Arrays
Linked lists
Applications of Stack
3. Introduction
Stack
The element deleted from the set is the one
most recently inserted
Last-in, First-out (LIFO)
D:DSAL5165 Advanced Algorithm and Programming Languageunit09.ppt
4. Introduction
Stack operations
PUSH: Insert
POP: Delete
TOP: return the key value of the most recently
inserted element
STACK-EMPTY: check if the stack is empty
STACK-FULL: check if the stack is full
5. An Example of Stack
2
8
1
7
2
7
2
1
7
2
1
7
2
8
1
7
2
8
1
7
2
top
top
top
top
top
top
Push(8) Push(2)
pop(2)
pop(8)pop(1)
D:Data StructuresICS202Lecture10.ppt
6. Implementation of Stacks
Any list implementation could be used to
implement a stack
Arrays (static: the size of stack is given initially)
Linked lists (dynamic: never become full)
We will explore implementations based on array
and linked list
Let’s see how to use an array to implement a
stack first
7. Represent Stack by Array
A stack of at most n elements can be implemented by an array
S[1..n]
top[S]: a pointer to the most recently inserted element
A stack consists of elements S[1..top[S]]
S[1]: the element at the bottom of the stack
S[top[S]]: the element at the top
11. 11
Nodes (data, pointer) connected in a chain by links
the head or the tail of the list could serve as the top of
the stack
Linked List Implementation
D:Data StructuresHanif_SearchQueuesad5.ppt
13. Applications of Stack
Direct applications
Parenthesis matching
Polish postfix and prefix notations
Expression evaluations
Undo sequence in a text editor
Handling function calls and return
Handling recursion
Indirect applications
Auxiliary data structure for algorithms
Component of other data structures
+++ many more
14. Parenthesis Matching (1/2)
To check that every right brace, bracket, and
parentheses must correspond to its left
counterpart
e.g. [( )] is legal, but [( ] ) is illegal
Dr. Hanif Durad 14
D:Data StructuresHanif_SearchStacks stack-queue.ppt,P-18/44
15. Parenthesis Matching (2/2)
Algorithm
(1) Make an empty stack.
(2) Read characters until end of file
i. If the character is an opening symbol, push it onto the stack
ii. If it is a closing symbol, then if the stack is empty, report an
error
iii. Otherwise, pop the stack. If the symbol popped is not the
corresponding opening symbol, then report an error
(3) At end of file, if the stack is not empty, report an err
Dr. Hanif Durad 15
17. 17
RPN or Postfix Notation
Most compilers convert an expression in infix
notation to postfix
the operators are written after the operands
So a * b + c becomes a b * c +
Advantage:
expressions can be written without parentheses
chapter07.ppt
18. 18
Postfix and Prefix Examples
INFIX RPN (POSTFIX) PREFIX
A + B
A * B + C
A * (B + C)
A - (B - (C - D))
A - B - C - D
* A + B C
+ * A B C
-A-B-C D
---A B C D
+ A B
Prefix : Operators come before
the operands
A B +
A B * C +
A B C + *
A B C D---
A B-C-D-
19. Algorithm for Infix to Postfix
1) Examine the next element in the input.
2) If it is operand, output it.
3) If it is opening parenthesis, push it on stack.
4) If it is an operator, then
i) If stack is empty, push operator on stack.
ii) If the top of stack is opening parenthesis, push operator on stack
iii) If it has higher priority than the top of stack, push operator on
stack.
iv) Else pop the operator from the stack and output it, repeat step 4
5) If it is a closing parenthesis, pop operators from stack and output
them until an opening parenthesis is encountered. pop and discard
the opening parenthesis.
6) If there is more input go to step 1
7) If there is no more input, pop the remaining operators to output.
Lecture 10,11 Stacks.pptx
20. Suppose we want to convert 2*3/(2-1)+5*3 into Postfix form,
So, the Postfix Expression is 23*21-/53*+
2 Empty 2
* * 2
3 * 23
/ / 23*
( /( 23*
2 /( 23*2
- /(- 23*2
1 /(- 23*21
) / 23*21-
+ + 23*21-/
5 + 23*21-/5
3 +* 23*21-/53
Expression Stack Output
* +* 23*21-/53
Empty 23*21-/53*+
21. Evaluation a postfix expression
• Each operator in a postfix string refers to the
previous two operands in the string.
• Suppose that each time we read an operand we
push it into a stack. When we reach an operator,
its operands will then be top two elements on the
stack
• We can then pop these two elements, perform the
indicated operation on them, and push the result
on the stack.
• So that it will be available for use as an operand of
the next operator.
22. Evaluating Postfix Notation
• Use a stack to evaluate an expression
in postfix notation.
• The postfix expression to be evaluated
is scanned from left to right.
• Variables or constants are pushed onto
the stack.
• When an operator is encountered, the
indicated action is performed using the
top elements of the stack, and the result
replaces the operands on the stack.
23. Evaluating a postfix expression
• Initialise an empty stack
• While token remain in the input stream
–Read next token
–If token is a number, push it into the stack
–Else, if token is an operator, pop top two
tokens off the stack,apply the operator, and
push the answer back into the stack
• Pop the answer off the stack.
26. Function calls
Programming languages use stacks to keep track of
function calls
When a function call occurs
Push CPU registers and program counter on to stack
(“activation record” or “stack frame”)
Upon return, restore registers and program counter from
top stack frame and pop
Dr. Hanif Durad 26
D:Data StructuresCPT S 223adt.ppt, P-47/52