SlideShare a Scribd company logo
1 of 45
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
1
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
 Understand all the aspects of a stack as data type including :
 Last In, First Out (LIFO) data access
 Push, Pop, and other stack operations
 Contiguous implementation of a stack
 Learn realization of stack using arrays(: Contiguous stack)
 Learn to choose appropriate realization suitable for practical
applications
 Learn and implement the multi-stacks
 Use of stacks in expression conversion, recursion, reversing data and
many more
2
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
3
 A stack is an ordered list in which all insertions and deletions
are made at one end, called the top
 In computer programming processing of function calls and
their terminations uses stack. Stack is used to remember the
place where the call was made; so that it can return there after
the function is complete
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
Following are some examples in which where we need to use
stacks are generally used:
Applications that maintain a list of printing jobs waiting at the a
network printer. Here we need to keep one queue which can hold
all print requests from different users
Handling function calls in programs very often restricts the
access only at one end. In such implementation we need to use
stacks. We can keep track of the return address to earlier function
after furnishing/finishing a function call using stacks
 If we intend to store a group of data together in a sequential
manner in computer’s memory, then arrays can be one of the
possible data structures.
4
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
 An array is a finite ordered collection of homogeneous data
elements which provides direct access (or random access) to
any of its elements.
 An array as a data structure is defined as a set of pairs (index,
value) such that with each index a value is associated.
index — indicates the location of an element in an array.
value - indicates the actual value of that data element.
 Declaration of an array in ‘C++’:
int Array_A[20];
5
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
6
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
7
The Stack Full Condition (Stack
Capacity =3)
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
8
The Pop Operation
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
9
The Empty Stack
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
10
The Get Top Operation
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
11
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
12
 A polish Mathematician Han Lukasiewicz suggested a notation
called polish notation, which gives two alternatives to represent an
arithmetic expression the notations are Postfix and prefix notation
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
13
……….. C B A
p
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
14
Stacks Using Template
 A template is variable which can be instantiated to any
data type
 This data type could be build in or user defined type
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
15
Initial configuration for two stacks in A[0],, …, A[n-1]
………..1 2 3 B A
Stack2Stack 1
A
Top1 =2 Top2=n-2
0 1 2 3 n-3
n-2
n-1
15
16
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
Initial configuration for m stacks in A [0,
…, n-1]
B[0]
T[0]
B[1]
T[1]
B[2]
T[2]
B[m-1]
T[m-1]
0 n/m 2[n/m] N-1
A
17
Applications Of Stack
 Convert infix expression to postfix and prefix
expressions
 Evaluate the postfix expression
 Reverse a string
 Check well-formed (nested) parenthesis
 Reverse a string
 Process subprogram function calls
 Parse (analyze the structure) of computer programs
 Simulate recursion
 In computations like decimal to binary conversion
 In Backtracking algorithms (often used in
optimizations
and in games)
18
Expression Evaluation And
Conversion
 The most frequent application of stacks is in evaluation of
arithmetic expressions.
 An arithmetic expression is made up of operands, operators,
and delimiters.
 When higher level programming language came into existence
one of the major difficulty faced by computer scientists was to
generate machine language instruction, which would properly
evaluate any arithmetic expression.
19
The following operators are written is in
descending order of their precedence:
 Exponentiation ^, Unary +, Unary –, and not ~
 Multiplication * and division /
 Addition + and subtraction –
 <, £ , =, ¹, ³, >
 AND
 OR
20
The Operators and priorities
Oxferd UnivercityData Structures in C++ by Dr. Varsha Patil
21
Polish Notation and Expression Conversion:
Polish Mathematician Han Lukasiewicz suggested a notation
called pPolish notation, which gives two alternatives to
represent an arithmetic expression, the notation are postfix
and prefix notations
The fundamental property of Polish notation is that the order
in which the operations are to be performed is determined by the
positions of the operators and operands in the expression.
Hence the advantage is parenthesis is not required while writing
expressions in pPolish notation
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
22
…The example expression in various forms-
infix, prefix and postfix
The postfix expressions can be evaluated easily hence infix
expression is converted into postfix expression using stack.
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
Repetition Construct
23
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
24
Relationship between Data, Data
Structures, and Algorithms
 A data structure represents a set of data items with a specific
relationship between them
 The success of a software project often depends upon the choices
made in the representation of data and algorithms designed to
process the data
 The proper choice of a data structure can be a key point in the
design of many algorithms
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
25
Flow Charts
A very effective tool to show the logic flow of a program
A flow chart is a pictorial representation of an algorithm
It hides all of the details of an algorithm by giving the picture;
It shows how the algorithm flows from beginning to end
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
26
Flow Charts
Flow chart for adding three numbers
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
27
Analysis of Algorithms
Complexity of Algorithms
 Space Complexity
 Time Complexity
 Computing Time Complexity of Algorithm
 Big-O Notation
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
28
Space Complexity
 Amount of computer memory required during the program
execution, as a function of the input size
 Space complexity measurement which is space requirement of
an algorithm can be done at two different times:
 Compile time and
 Execution time
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
29
Compile time space
complexity
 Compile time space complexity is defined as the storage
requirement of a program at compile time
 The space complexity = Space needed of compile time
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
30
Runtime space
complexity
 If program is recursive or uses dynamic variables or dynamic
data structure then there is a need to determine space
complexity at runtime
 The memory requirement is summation of the
 program space
 data space and
 stack space
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
31
Time Complexity
 The time complexity of an algorithm is a measure of how much
time is required to execute an algorithm for a given number of
inputs
 Time Complexity T(P) is the time taken by program P and the
sum of the compile and execution time
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
32
Best, Worst and Average Cases
 The worst case :
Complexity of the algorithm is the function defined by the
maximum number of steps taken on any instance of size n
 The best case:
Complexity of the algorithm is the function defined by the
minimum number of steps taken on any instance of size n
 The average case:
Complexity of the algorithm is the function defined by an
average number of steps taken on any instance of size n.
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
33
Computing Time Complexity of
Algorithm
The total time taken by the algorithm or program is calculated
using the sum of the time taken by each of executable statement in
algorithm or program
Time required by each statement depends on
 Time required for executing it once.
 Number of times the statement is executed.
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
34
Software Engineering
Software Engineering is the establishment and use of sound
engineering methods and principles to obtain reliable software that
works on real machines.
A fundamental concept in Software Engineering is the Software
Development Life
Cycle (SDLC)
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
35
Software Engineering
Analysis Phase
Design Phase
Implementation Phase
Testing Phase
Verification
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
36
Software Engineering
Analysis Phase
Design Phase
Implementation Phase
Testing Phase
Verification
System Development Phases
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
37
Analysis Phase
Define the User
Define the Needs
Design Phase
Define the Methods
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
38
Design Phase
Modularity:
The design phase uses a very well-established principle called
modularity
The whole package is divided into small modules
Tools
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
39
Implementation Phase
Tools
flowchart
Pseudo Code
Coding
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
40
Testing Phase
Testing Phase
Once the programs have been written, they must be
tested.
There are two types of testing:
 Black box and
 White box
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
41
Verification
Program verification is a process to prove that the
program does what it is intended to do.
It is said that 'even verification must be verified'.
This means, along with system, tests made are to be
verified.
Also, every software quality must be verified.
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
42
Summary
 A stack is an ordered list in which all insertions and deletions are
made at one end, called the top
 Adding an element is called as pushing the element onto the
stack. The function, which does this, is called ‘push’.
 Removing an element from the stack is called as popping the
element from the stack and the function, which does this, is
called ‘pop’
 Stack can be implemented using arrays or using linked lists.
 For array implementation its size should be predefined and also it
cannot exceed run time
 Stack is used in wide number of applications such as recursion,
expression conversion, well -formed parenthesis check etc..
 Program verification is a process to prove that the program does
what it is intended to do
 It is said that 'even verification must be verified'
 This means, along with system, tests made are to be verified.
 Also, every software quality must be verified
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
43
Summary
The most frequent application of stack is in evaluation of arithmetic
expressions. The conventional way of writing the expression is called infix,
because the binary operators occur in between the operands and unary
operators precede their operand.
Polish Mathematician Han Lukasiewicz suggested a notation called Polish
notion, which gives two alternatives to represent an arithmetic
expression, the notations are postfix and prefix notations.
In postfix notation, the operator is written after its operands, whereas in
prefix notation the operator precedes its operands.·
The postfix expressions can be evaluated easily hence infix expression is
converted into postfix expression using stack.
In computer programming processing of function calls and their terminations
uses stack.
Stack is used to remember the place where the call was made; so that it can
return there after the function is complet the check etc..
Program verification is a process to prove that the program does what it is
intended to do.
It is said that 'even verification must be verified'.
This means, along with system, tests made are to be verified.
Also, every software quality must be verified.
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
44
Key Terms
 Data
 Data type
 DATA OBJECT
 DATA STRUCTURE
 ABSTRACT DATA TYPE
 LINEAR DATA STRUCUTRE
 NON LINEAR DATA STRUCTURE
 ALGORITHM
 ASSEMBLER
 COMPILER
 Program
 Pseudo code
 Flowchart
 Software Engineering
45
End
of
Chapter 3 …!

More Related Content

What's hot

Lecture notes data structures tree
Lecture notes data structures   treeLecture notes data structures   tree
Lecture notes data structures treemaamir farooq
 
sparse matrix in data structure
sparse matrix in data structuresparse matrix in data structure
sparse matrix in data structureMAHALAKSHMI P
 
Sparse matrix and its representation data structure
Sparse matrix and its representation data structureSparse matrix and its representation data structure
Sparse matrix and its representation data structureVardhil Patel
 
Introduction to Array ppt
Introduction to Array pptIntroduction to Array ppt
Introduction to Array pptsandhya yadav
 
Presentation on Data Structure
Presentation on Data StructurePresentation on Data Structure
Presentation on Data StructureA. N. M. Jubaer
 
concept of Array, 1D & 2D array
concept of Array, 1D & 2D arrayconcept of Array, 1D & 2D array
concept of Array, 1D & 2D arraySangani Ankur
 
Two Dimensional Array
Two Dimensional ArrayTwo Dimensional Array
Two Dimensional Arraydincyjain
 
Multi dimensional arrays
Multi dimensional arraysMulti dimensional arrays
Multi dimensional arraysAseelhalees
 
Library functions in c++
Library functions in c++Library functions in c++
Library functions in c++Neeru Mittal
 
Data Structures and Algorithm Analysis
Data Structures  and  Algorithm AnalysisData Structures  and  Algorithm Analysis
Data Structures and Algorithm AnalysisMary Margarat
 
One Dimensional Array
One Dimensional Array One Dimensional Array
One Dimensional Array dincyjain
 
Introduction to data structure
Introduction to data structure Introduction to data structure
Introduction to data structure NUPOORAWSARMOL
 
19. Data Structures and Algorithm Complexity
19. Data Structures and Algorithm Complexity19. Data Structures and Algorithm Complexity
19. Data Structures and Algorithm ComplexityIntro C# Book
 

What's hot (20)

Lecture notes data structures tree
Lecture notes data structures   treeLecture notes data structures   tree
Lecture notes data structures tree
 
Tree - Data Structure
Tree - Data StructureTree - Data Structure
Tree - Data Structure
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
sparse matrix in data structure
sparse matrix in data structuresparse matrix in data structure
sparse matrix in data structure
 
Chapter 05 classes and objects
Chapter 05 classes and objectsChapter 05 classes and objects
Chapter 05 classes and objects
 
Sparse matrix and its representation data structure
Sparse matrix and its representation data structureSparse matrix and its representation data structure
Sparse matrix and its representation data structure
 
Namespaces
NamespacesNamespaces
Namespaces
 
Introduction to Array ppt
Introduction to Array pptIntroduction to Array ppt
Introduction to Array ppt
 
Stack and Queue
Stack and Queue Stack and Queue
Stack and Queue
 
Presentation on Data Structure
Presentation on Data StructurePresentation on Data Structure
Presentation on Data Structure
 
concept of Array, 1D & 2D array
concept of Array, 1D & 2D arrayconcept of Array, 1D & 2D array
concept of Array, 1D & 2D array
 
Two Dimensional Array
Two Dimensional ArrayTwo Dimensional Array
Two Dimensional Array
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
 
Multi dimensional arrays
Multi dimensional arraysMulti dimensional arrays
Multi dimensional arrays
 
Library functions in c++
Library functions in c++Library functions in c++
Library functions in c++
 
Data Structures and Algorithm Analysis
Data Structures  and  Algorithm AnalysisData Structures  and  Algorithm Analysis
Data Structures and Algorithm Analysis
 
One Dimensional Array
One Dimensional Array One Dimensional Array
One Dimensional Array
 
Introduction to data structure
Introduction to data structure Introduction to data structure
Introduction to data structure
 
Sql operators & functions 3
Sql operators & functions 3Sql operators & functions 3
Sql operators & functions 3
 
19. Data Structures and Algorithm Complexity
19. Data Structures and Algorithm Complexity19. Data Structures and Algorithm Complexity
19. Data Structures and Algorithm Complexity
 

Viewers also liked

6. Linked list - Data Structures using C++ by Varsha Patil
6. Linked list - Data Structures using C++ by Varsha Patil6. Linked list - Data Structures using C++ by Varsha Patil
6. Linked list - Data Structures using C++ by Varsha Patilwidespreadpromotion
 
7. Tree - Data Structures using C++ by Varsha Patil
7. Tree - Data Structures using C++ by Varsha Patil7. Tree - Data Structures using C++ by Varsha Patil
7. Tree - Data Structures using C++ by Varsha Patilwidespreadpromotion
 
5. Queue - Data Structures using C++ by Varsha Patil
5. Queue - Data Structures using C++ by Varsha Patil5. Queue - Data Structures using C++ by Varsha Patil
5. Queue - Data Structures using C++ by Varsha Patilwidespreadpromotion
 
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. PatilDiscrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. Patilwidespreadpromotion
 
Data Structure
Data StructureData Structure
Data Structuresheraz1
 
10. Search Tree - Data Structures using C++ by Varsha Patil
10. Search Tree - Data Structures using C++ by Varsha Patil10. Search Tree - Data Structures using C++ by Varsha Patil
10. Search Tree - Data Structures using C++ by Varsha Patilwidespreadpromotion
 
8. Graph - Data Structures using C++ by Varsha Patil
8. Graph - Data Structures using C++ by Varsha Patil8. Graph - Data Structures using C++ by Varsha Patil
8. Graph - Data Structures using C++ by Varsha Patilwidespreadpromotion
 
15. STL - Data Structures using C++ by Varsha Patil
15. STL - Data Structures using C++ by Varsha Patil15. STL - Data Structures using C++ by Varsha Patil
15. STL - Data Structures using C++ by Varsha Patilwidespreadpromotion
 
14. Files - Data Structures using C++ by Varsha Patil
14. Files - Data Structures using C++ by Varsha Patil14. Files - Data Structures using C++ by Varsha Patil
14. Files - Data Structures using C++ by Varsha Patilwidespreadpromotion
 
Stack data structure
Stack data structureStack data structure
Stack data structureTech_MX
 
1. Fundamental Concept - Data Structures using C++ by Varsha Patil
1. Fundamental Concept - Data Structures using C++ by Varsha Patil1. Fundamental Concept - Data Structures using C++ by Varsha Patil
1. Fundamental Concept - Data Structures using C++ by Varsha Patilwidespreadpromotion
 
12. Heaps - Data Structures using C++ by Varsha Patil
12. Heaps - Data Structures using C++ by Varsha Patil12. Heaps - Data Structures using C++ by Varsha Patil
12. Heaps - Data Structures using C++ by Varsha Patilwidespreadpromotion
 
Applications of stack
Applications of stackApplications of stack
Applications of stackeShikshak
 

Viewers also liked (20)

6. Linked list - Data Structures using C++ by Varsha Patil
6. Linked list - Data Structures using C++ by Varsha Patil6. Linked list - Data Structures using C++ by Varsha Patil
6. Linked list - Data Structures using C++ by Varsha Patil
 
7. Tree - Data Structures using C++ by Varsha Patil
7. Tree - Data Structures using C++ by Varsha Patil7. Tree - Data Structures using C++ by Varsha Patil
7. Tree - Data Structures using C++ by Varsha Patil
 
5. Queue - Data Structures using C++ by Varsha Patil
5. Queue - Data Structures using C++ by Varsha Patil5. Queue - Data Structures using C++ by Varsha Patil
5. Queue - Data Structures using C++ by Varsha Patil
 
Stacks in c++
Stacks in c++Stacks in c++
Stacks in c++
 
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. PatilDiscrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
 
Data Structure
Data StructureData Structure
Data Structure
 
10. Search Tree - Data Structures using C++ by Varsha Patil
10. Search Tree - Data Structures using C++ by Varsha Patil10. Search Tree - Data Structures using C++ by Varsha Patil
10. Search Tree - Data Structures using C++ by Varsha Patil
 
8. Graph - Data Structures using C++ by Varsha Patil
8. Graph - Data Structures using C++ by Varsha Patil8. Graph - Data Structures using C++ by Varsha Patil
8. Graph - Data Structures using C++ by Varsha Patil
 
15. STL - Data Structures using C++ by Varsha Patil
15. STL - Data Structures using C++ by Varsha Patil15. STL - Data Structures using C++ by Varsha Patil
15. STL - Data Structures using C++ by Varsha Patil
 
14. Files - Data Structures using C++ by Varsha Patil
14. Files - Data Structures using C++ by Varsha Patil14. Files - Data Structures using C++ by Varsha Patil
14. Files - Data Structures using C++ by Varsha Patil
 
Stack data structure
Stack data structureStack data structure
Stack data structure
 
1. Fundamental Concept - Data Structures using C++ by Varsha Patil
1. Fundamental Concept - Data Structures using C++ by Varsha Patil1. Fundamental Concept - Data Structures using C++ by Varsha Patil
1. Fundamental Concept - Data Structures using C++ by Varsha Patil
 
12. Heaps - Data Structures using C++ by Varsha Patil
12. Heaps - Data Structures using C++ by Varsha Patil12. Heaps - Data Structures using C++ by Varsha Patil
12. Heaps - Data Structures using C++ by Varsha Patil
 
Linked list
Linked listLinked list
Linked list
 
Applications of stack
Applications of stackApplications of stack
Applications of stack
 
Stack
StackStack
Stack
 
Linked lists
Linked listsLinked lists
Linked lists
 
Lec5
Lec5Lec5
Lec5
 
Ch17
Ch17Ch17
Ch17
 
Python - Logic Gates
Python - Logic GatesPython - Logic Gates
Python - Logic Gates
 

Similar to 3. Stack - Data Structures using C++ by Varsha Patil

16. Algo analysis & Design - Data Structures using C++ by Varsha Patil
16. Algo analysis & Design - Data Structures using C++ by Varsha Patil16. Algo analysis & Design - Data Structures using C++ by Varsha Patil
16. Algo analysis & Design - Data Structures using C++ by Varsha Patilwidespreadpromotion
 
4. Recursion - Data Structures using C++ by Varsha Patil
4. Recursion - Data Structures using C++ by Varsha Patil4. Recursion - Data Structures using C++ by Varsha Patil
4. Recursion - Data Structures using C++ by Varsha Patilwidespreadpromotion
 
Stacks in algorithems & data structure
Stacks in algorithems & data structureStacks in algorithems & data structure
Stacks in algorithems & data structurefaran nawaz
 
Swift Parallel Scripting for High-Performance Workflow
Swift Parallel Scripting for High-Performance WorkflowSwift Parallel Scripting for High-Performance Workflow
Swift Parallel Scripting for High-Performance WorkflowDaniel S. Katz
 
Automatic Task-based Code Generation for High Performance DSEL
Automatic Task-based Code Generation for High Performance DSELAutomatic Task-based Code Generation for High Performance DSEL
Automatic Task-based Code Generation for High Performance DSELJoel Falcou
 
9. Searching & Sorting - Data Structures using C++ by Varsha Patil
9. Searching & Sorting - Data Structures using C++ by Varsha Patil9. Searching & Sorting - Data Structures using C++ by Varsha Patil
9. Searching & Sorting - Data Structures using C++ by Varsha Patilwidespreadpromotion
 
A project on advanced C language
A project on advanced C languageA project on advanced C language
A project on advanced C languagesvrohith 9
 
Principal of objected oriented programming
Principal of objected oriented programming Principal of objected oriented programming
Principal of objected oriented programming Rokonuzzaman Rony
 
Parallel Computing 2007: Overview
Parallel Computing 2007: OverviewParallel Computing 2007: Overview
Parallel Computing 2007: OverviewGeoffrey Fox
 
Exploring Emerging Technologies in the Extreme Scale HPC Co-Design Space with...
Exploring Emerging Technologies in the Extreme Scale HPC Co-Design Space with...Exploring Emerging Technologies in the Extreme Scale HPC Co-Design Space with...
Exploring Emerging Technologies in the Extreme Scale HPC Co-Design Space with...jsvetter
 
IJSETR-VOL-3-ISSUE-12-3358-3363
IJSETR-VOL-3-ISSUE-12-3358-3363IJSETR-VOL-3-ISSUE-12-3358-3363
IJSETR-VOL-3-ISSUE-12-3358-3363SHIVA REDDY
 
computer notes - Data Structures - 1
computer notes - Data Structures - 1computer notes - Data Structures - 1
computer notes - Data Structures - 1ecomputernotes
 

Similar to 3. Stack - Data Structures using C++ by Varsha Patil (20)

16. Algo analysis & Design - Data Structures using C++ by Varsha Patil
16. Algo analysis & Design - Data Structures using C++ by Varsha Patil16. Algo analysis & Design - Data Structures using C++ by Varsha Patil
16. Algo analysis & Design - Data Structures using C++ by Varsha Patil
 
4. Recursion - Data Structures using C++ by Varsha Patil
4. Recursion - Data Structures using C++ by Varsha Patil4. Recursion - Data Structures using C++ by Varsha Patil
4. Recursion - Data Structures using C++ by Varsha Patil
 
Stacks in algorithems & data structure
Stacks in algorithems & data structureStacks in algorithems & data structure
Stacks in algorithems & data structure
 
Swift Parallel Scripting for High-Performance Workflow
Swift Parallel Scripting for High-Performance WorkflowSwift Parallel Scripting for High-Performance Workflow
Swift Parallel Scripting for High-Performance Workflow
 
Automatic Task-based Code Generation for High Performance DSEL
Automatic Task-based Code Generation for High Performance DSELAutomatic Task-based Code Generation for High Performance DSEL
Automatic Task-based Code Generation for High Performance DSEL
 
9. Searching & Sorting - Data Structures using C++ by Varsha Patil
9. Searching & Sorting - Data Structures using C++ by Varsha Patil9. Searching & Sorting - Data Structures using C++ by Varsha Patil
9. Searching & Sorting - Data Structures using C++ by Varsha Patil
 
Lec1
Lec1Lec1
Lec1
 
A project on advanced C language
A project on advanced C languageA project on advanced C language
A project on advanced C language
 
Structure
StructureStructure
Structure
 
Lect1.pptx
Lect1.pptxLect1.pptx
Lect1.pptx
 
Principal of objected oriented programming
Principal of objected oriented programming Principal of objected oriented programming
Principal of objected oriented programming
 
Sorting_project_2.pdf
Sorting_project_2.pdfSorting_project_2.pdf
Sorting_project_2.pdf
 
Parallel Computing 2007: Overview
Parallel Computing 2007: OverviewParallel Computing 2007: Overview
Parallel Computing 2007: Overview
 
Exploring Emerging Technologies in the Extreme Scale HPC Co-Design Space with...
Exploring Emerging Technologies in the Extreme Scale HPC Co-Design Space with...Exploring Emerging Technologies in the Extreme Scale HPC Co-Design Space with...
Exploring Emerging Technologies in the Extreme Scale HPC Co-Design Space with...
 
Ch14
Ch14Ch14
Ch14
 
IJSETR-VOL-3-ISSUE-12-3358-3363
IJSETR-VOL-3-ISSUE-12-3358-3363IJSETR-VOL-3-ISSUE-12-3358-3363
IJSETR-VOL-3-ISSUE-12-3358-3363
 
CLIM Program: Remote Sensing Workshop, An Introduction to Systems and Softwar...
CLIM Program: Remote Sensing Workshop, An Introduction to Systems and Softwar...CLIM Program: Remote Sensing Workshop, An Introduction to Systems and Softwar...
CLIM Program: Remote Sensing Workshop, An Introduction to Systems and Softwar...
 
c++ referesher 1.pdf
c++ referesher 1.pdfc++ referesher 1.pdf
c++ referesher 1.pdf
 
computer notes - Data Structures - 1
computer notes - Data Structures - 1computer notes - Data Structures - 1
computer notes - Data Structures - 1
 
rscript_paper-1
rscript_paper-1rscript_paper-1
rscript_paper-1
 

Recently uploaded

SMOTE and K-Fold Cross Validation-Presentation.pptx
SMOTE and K-Fold Cross Validation-Presentation.pptxSMOTE and K-Fold Cross Validation-Presentation.pptx
SMOTE and K-Fold Cross Validation-Presentation.pptxHaritikaChhatwal1
 
World Economic Forum Metaverse Ecosystem By Utpal Chakraborty.pdf
World Economic Forum Metaverse Ecosystem By Utpal Chakraborty.pdfWorld Economic Forum Metaverse Ecosystem By Utpal Chakraborty.pdf
World Economic Forum Metaverse Ecosystem By Utpal Chakraborty.pdfsimulationsindia
 
Learn How Data Science Changes Our World
Learn How Data Science Changes Our WorldLearn How Data Science Changes Our World
Learn How Data Science Changes Our WorldEduminds Learning
 
Decoding Movie Sentiments: Analyzing Reviews with Data Analysis model
Decoding Movie Sentiments: Analyzing Reviews with Data Analysis modelDecoding Movie Sentiments: Analyzing Reviews with Data Analysis model
Decoding Movie Sentiments: Analyzing Reviews with Data Analysis modelBoston Institute of Analytics
 
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...Amil Baba Dawood bangali
 
Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Seán Kennedy
 
English-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdf
English-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdfEnglish-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdf
English-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdfblazblazml
 
Decoding Patterns: Customer Churn Prediction Data Analysis Project
Decoding Patterns: Customer Churn Prediction Data Analysis ProjectDecoding Patterns: Customer Churn Prediction Data Analysis Project
Decoding Patterns: Customer Churn Prediction Data Analysis ProjectBoston Institute of Analytics
 
6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...
6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...
6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...Dr Arash Najmaei ( Phd., MBA, BSc)
 
The Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptx
The Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptxThe Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptx
The Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptxTasha Penwell
 
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...Boston Institute of Analytics
 
Data Factory in Microsoft Fabric (MsBIP #82)
Data Factory in Microsoft Fabric (MsBIP #82)Data Factory in Microsoft Fabric (MsBIP #82)
Data Factory in Microsoft Fabric (MsBIP #82)Cathrine Wilhelmsen
 
IBEF report on the Insurance market in India
IBEF report on the Insurance market in IndiaIBEF report on the Insurance market in India
IBEF report on the Insurance market in IndiaManalVerma4
 
What To Do For World Nature Conservation Day by Slidesgo.pptx
What To Do For World Nature Conservation Day by Slidesgo.pptxWhat To Do For World Nature Conservation Day by Slidesgo.pptx
What To Do For World Nature Conservation Day by Slidesgo.pptxSimranPal17
 
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...Boston Institute of Analytics
 
why-transparency-and-traceability-are-essential-for-sustainable-supply-chains...
why-transparency-and-traceability-are-essential-for-sustainable-supply-chains...why-transparency-and-traceability-are-essential-for-sustainable-supply-chains...
why-transparency-and-traceability-are-essential-for-sustainable-supply-chains...Jack Cole
 
Semantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxSemantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxMike Bennett
 
Cyber awareness ppt on the recorded data
Cyber awareness ppt on the recorded dataCyber awareness ppt on the recorded data
Cyber awareness ppt on the recorded dataTecnoIncentive
 

Recently uploaded (20)

SMOTE and K-Fold Cross Validation-Presentation.pptx
SMOTE and K-Fold Cross Validation-Presentation.pptxSMOTE and K-Fold Cross Validation-Presentation.pptx
SMOTE and K-Fold Cross Validation-Presentation.pptx
 
World Economic Forum Metaverse Ecosystem By Utpal Chakraborty.pdf
World Economic Forum Metaverse Ecosystem By Utpal Chakraborty.pdfWorld Economic Forum Metaverse Ecosystem By Utpal Chakraborty.pdf
World Economic Forum Metaverse Ecosystem By Utpal Chakraborty.pdf
 
Learn How Data Science Changes Our World
Learn How Data Science Changes Our WorldLearn How Data Science Changes Our World
Learn How Data Science Changes Our World
 
Decoding Movie Sentiments: Analyzing Reviews with Data Analysis model
Decoding Movie Sentiments: Analyzing Reviews with Data Analysis modelDecoding Movie Sentiments: Analyzing Reviews with Data Analysis model
Decoding Movie Sentiments: Analyzing Reviews with Data Analysis model
 
Data Analysis Project: Stroke Prediction
Data Analysis Project: Stroke PredictionData Analysis Project: Stroke Prediction
Data Analysis Project: Stroke Prediction
 
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
 
Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...
 
English-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdf
English-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdfEnglish-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdf
English-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdf
 
Decoding Patterns: Customer Churn Prediction Data Analysis Project
Decoding Patterns: Customer Churn Prediction Data Analysis ProjectDecoding Patterns: Customer Churn Prediction Data Analysis Project
Decoding Patterns: Customer Churn Prediction Data Analysis Project
 
6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...
6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...
6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...
 
The Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptx
The Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptxThe Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptx
The Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptx
 
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...
 
Data Factory in Microsoft Fabric (MsBIP #82)
Data Factory in Microsoft Fabric (MsBIP #82)Data Factory in Microsoft Fabric (MsBIP #82)
Data Factory in Microsoft Fabric (MsBIP #82)
 
Insurance Churn Prediction Data Analysis Project
Insurance Churn Prediction Data Analysis ProjectInsurance Churn Prediction Data Analysis Project
Insurance Churn Prediction Data Analysis Project
 
IBEF report on the Insurance market in India
IBEF report on the Insurance market in IndiaIBEF report on the Insurance market in India
IBEF report on the Insurance market in India
 
What To Do For World Nature Conservation Day by Slidesgo.pptx
What To Do For World Nature Conservation Day by Slidesgo.pptxWhat To Do For World Nature Conservation Day by Slidesgo.pptx
What To Do For World Nature Conservation Day by Slidesgo.pptx
 
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
 
why-transparency-and-traceability-are-essential-for-sustainable-supply-chains...
why-transparency-and-traceability-are-essential-for-sustainable-supply-chains...why-transparency-and-traceability-are-essential-for-sustainable-supply-chains...
why-transparency-and-traceability-are-essential-for-sustainable-supply-chains...
 
Semantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxSemantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptx
 
Cyber awareness ppt on the recorded data
Cyber awareness ppt on the recorded dataCyber awareness ppt on the recorded data
Cyber awareness ppt on the recorded data
 

3. Stack - Data Structures using C++ by Varsha Patil

  • 1. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 1
  • 2. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil  Understand all the aspects of a stack as data type including :  Last In, First Out (LIFO) data access  Push, Pop, and other stack operations  Contiguous implementation of a stack  Learn realization of stack using arrays(: Contiguous stack)  Learn to choose appropriate realization suitable for practical applications  Learn and implement the multi-stacks  Use of stacks in expression conversion, recursion, reversing data and many more 2
  • 3. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 3  A stack is an ordered list in which all insertions and deletions are made at one end, called the top  In computer programming processing of function calls and their terminations uses stack. Stack is used to remember the place where the call was made; so that it can return there after the function is complete
  • 4. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil Following are some examples in which where we need to use stacks are generally used: Applications that maintain a list of printing jobs waiting at the a network printer. Here we need to keep one queue which can hold all print requests from different users Handling function calls in programs very often restricts the access only at one end. In such implementation we need to use stacks. We can keep track of the return address to earlier function after furnishing/finishing a function call using stacks  If we intend to store a group of data together in a sequential manner in computer’s memory, then arrays can be one of the possible data structures. 4
  • 5. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil  An array is a finite ordered collection of homogeneous data elements which provides direct access (or random access) to any of its elements.  An array as a data structure is defined as a set of pairs (index, value) such that with each index a value is associated. index — indicates the location of an element in an array. value - indicates the actual value of that data element.  Declaration of an array in ‘C++’: int Array_A[20]; 5
  • 6. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 6
  • 7. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 7 The Stack Full Condition (Stack Capacity =3)
  • 8. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 8 The Pop Operation
  • 9. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 9 The Empty Stack
  • 10. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 10 The Get Top Operation
  • 11. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 11
  • 12. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 12  A polish Mathematician Han Lukasiewicz suggested a notation called polish notation, which gives two alternatives to represent an arithmetic expression the notations are Postfix and prefix notation
  • 13. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 13 ……….. C B A p
  • 14. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 14 Stacks Using Template  A template is variable which can be instantiated to any data type  This data type could be build in or user defined type
  • 15. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 15 Initial configuration for two stacks in A[0],, …, A[n-1] ………..1 2 3 B A Stack2Stack 1 A Top1 =2 Top2=n-2 0 1 2 3 n-3 n-2 n-1 15
  • 16. 16 Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil Initial configuration for m stacks in A [0, …, n-1] B[0] T[0] B[1] T[1] B[2] T[2] B[m-1] T[m-1] 0 n/m 2[n/m] N-1 A
  • 17. 17 Applications Of Stack  Convert infix expression to postfix and prefix expressions  Evaluate the postfix expression  Reverse a string  Check well-formed (nested) parenthesis  Reverse a string  Process subprogram function calls  Parse (analyze the structure) of computer programs  Simulate recursion  In computations like decimal to binary conversion  In Backtracking algorithms (often used in optimizations and in games)
  • 18. 18 Expression Evaluation And Conversion  The most frequent application of stacks is in evaluation of arithmetic expressions.  An arithmetic expression is made up of operands, operators, and delimiters.  When higher level programming language came into existence one of the major difficulty faced by computer scientists was to generate machine language instruction, which would properly evaluate any arithmetic expression.
  • 19. 19 The following operators are written is in descending order of their precedence:  Exponentiation ^, Unary +, Unary –, and not ~  Multiplication * and division /  Addition + and subtraction –  <, £ , =, ¹, ³, >  AND  OR
  • 20. 20 The Operators and priorities Oxferd UnivercityData Structures in C++ by Dr. Varsha Patil
  • 21. 21 Polish Notation and Expression Conversion: Polish Mathematician Han Lukasiewicz suggested a notation called pPolish notation, which gives two alternatives to represent an arithmetic expression, the notation are postfix and prefix notations The fundamental property of Polish notation is that the order in which the operations are to be performed is determined by the positions of the operators and operands in the expression. Hence the advantage is parenthesis is not required while writing expressions in pPolish notation
  • 22. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 22 …The example expression in various forms- infix, prefix and postfix The postfix expressions can be evaluated easily hence infix expression is converted into postfix expression using stack.
  • 23. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil Repetition Construct 23
  • 24. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 24 Relationship between Data, Data Structures, and Algorithms  A data structure represents a set of data items with a specific relationship between them  The success of a software project often depends upon the choices made in the representation of data and algorithms designed to process the data  The proper choice of a data structure can be a key point in the design of many algorithms
  • 25. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 25 Flow Charts A very effective tool to show the logic flow of a program A flow chart is a pictorial representation of an algorithm It hides all of the details of an algorithm by giving the picture; It shows how the algorithm flows from beginning to end
  • 26. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 26 Flow Charts Flow chart for adding three numbers
  • 27. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 27 Analysis of Algorithms Complexity of Algorithms  Space Complexity  Time Complexity  Computing Time Complexity of Algorithm  Big-O Notation
  • 28. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 28 Space Complexity  Amount of computer memory required during the program execution, as a function of the input size  Space complexity measurement which is space requirement of an algorithm can be done at two different times:  Compile time and  Execution time
  • 29. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 29 Compile time space complexity  Compile time space complexity is defined as the storage requirement of a program at compile time  The space complexity = Space needed of compile time
  • 30. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 30 Runtime space complexity  If program is recursive or uses dynamic variables or dynamic data structure then there is a need to determine space complexity at runtime  The memory requirement is summation of the  program space  data space and  stack space
  • 31. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 31 Time Complexity  The time complexity of an algorithm is a measure of how much time is required to execute an algorithm for a given number of inputs  Time Complexity T(P) is the time taken by program P and the sum of the compile and execution time
  • 32. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 32 Best, Worst and Average Cases  The worst case : Complexity of the algorithm is the function defined by the maximum number of steps taken on any instance of size n  The best case: Complexity of the algorithm is the function defined by the minimum number of steps taken on any instance of size n  The average case: Complexity of the algorithm is the function defined by an average number of steps taken on any instance of size n.
  • 33. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 33 Computing Time Complexity of Algorithm The total time taken by the algorithm or program is calculated using the sum of the time taken by each of executable statement in algorithm or program Time required by each statement depends on  Time required for executing it once.  Number of times the statement is executed.
  • 34. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 34 Software Engineering Software Engineering is the establishment and use of sound engineering methods and principles to obtain reliable software that works on real machines. A fundamental concept in Software Engineering is the Software Development Life Cycle (SDLC)
  • 35. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 35 Software Engineering Analysis Phase Design Phase Implementation Phase Testing Phase Verification
  • 36. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 36 Software Engineering Analysis Phase Design Phase Implementation Phase Testing Phase Verification System Development Phases
  • 37. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 37 Analysis Phase Define the User Define the Needs Design Phase Define the Methods
  • 38. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 38 Design Phase Modularity: The design phase uses a very well-established principle called modularity The whole package is divided into small modules Tools
  • 39. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 39 Implementation Phase Tools flowchart Pseudo Code Coding
  • 40. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 40 Testing Phase Testing Phase Once the programs have been written, they must be tested. There are two types of testing:  Black box and  White box
  • 41. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 41 Verification Program verification is a process to prove that the program does what it is intended to do. It is said that 'even verification must be verified'. This means, along with system, tests made are to be verified. Also, every software quality must be verified.
  • 42. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 42 Summary  A stack is an ordered list in which all insertions and deletions are made at one end, called the top  Adding an element is called as pushing the element onto the stack. The function, which does this, is called ‘push’.  Removing an element from the stack is called as popping the element from the stack and the function, which does this, is called ‘pop’  Stack can be implemented using arrays or using linked lists.  For array implementation its size should be predefined and also it cannot exceed run time  Stack is used in wide number of applications such as recursion, expression conversion, well -formed parenthesis check etc..  Program verification is a process to prove that the program does what it is intended to do  It is said that 'even verification must be verified'  This means, along with system, tests made are to be verified.  Also, every software quality must be verified
  • 43. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 43 Summary The most frequent application of stack is in evaluation of arithmetic expressions. The conventional way of writing the expression is called infix, because the binary operators occur in between the operands and unary operators precede their operand. Polish Mathematician Han Lukasiewicz suggested a notation called Polish notion, which gives two alternatives to represent an arithmetic expression, the notations are postfix and prefix notations. In postfix notation, the operator is written after its operands, whereas in prefix notation the operator precedes its operands.· The postfix expressions can be evaluated easily hence infix expression is converted into postfix expression using stack. In computer programming processing of function calls and their terminations uses stack. Stack is used to remember the place where the call was made; so that it can return there after the function is complet the check etc.. Program verification is a process to prove that the program does what it is intended to do. It is said that 'even verification must be verified'. This means, along with system, tests made are to be verified. Also, every software quality must be verified.
  • 44. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 44 Key Terms  Data  Data type  DATA OBJECT  DATA STRUCTURE  ABSTRACT DATA TYPE  LINEAR DATA STRUCUTRE  NON LINEAR DATA STRUCTURE  ALGORITHM  ASSEMBLER  COMPILER  Program  Pseudo code  Flowchart  Software Engineering