Page 165 - DCAP201_FUNDAMENTALS_OF_DATA_STRUCTURES
P. 165
Fundamentals of Data Structures
Notes 9.6 Summary
A stack is an ordered collection of homogeneous data elements where the insertion and
deletion operations occur at one end only, called the top of the stack.
PUSH operation is used to insert the data elements in a stack. POP function is used for
deleting the elements from a stack.
A Stack contains an ordered list of elements and an array is also used to store ordered list
of elements.
In the case of a linked stack, we shall push and pop nodes from one end of a linked list.
We can define an array stack A with n elements and an array stack B with n elements.
1 2
Overflow may occur when either stack A contains more than n elements or stack B
1
contains more than n elements.
2
Parenthesis checker is an algorithm that confirms that the number of closing parenthesis
equals opening parenthesis by using stack.
Stacks are frequently used in evaluation of arithmetic expressions. An arithmetic expression
consists of operands and operators.
We can evaluate a postfix expression using a stack. Each operator in a postfix string
corresponds to the previous two operands.
A stack can also be used to convert an infix expression in standard form into postfix form.
9.7 Keywords
Arithmetic Expression: An arithmetic expression consists of operands and operators.
Multi stack: Multi stack is a program with more than one stack.
Parenthesis Checker: Parenthesis checker is an algorithm that confirms that the number of
closing parenthesis equals opening parenthesis by using stack.
PEEP: The process of verifying the item placed at the top of the stack without removing it is
called PEEP.
POP: POP function is used for deleting the elements from a stack.
PUSH: PUSH operation is used to insert the data elements in a stack.
Showelements Operation: Showelements will display the elements of the stack.
Stack: A stack is an ordered collection of homogeneous data elements where the insertion and
deletion operations occur at one end only, called the top of the stack.
9.8 Review Questions
1. Explain the concept of stack with example.
2. Discuss the operations performed on a stack. Give example.
3. Illustrate the use of PEEP operation with example.
4. Describe the implementation of push and pop operation.
5. Explain the Sequential Representation of Stacks. Illustrate with a program.
158 LOVELY PROFESSIONAL UNIVERSITY