STACK CHAPTER 03 Developed By :- Misha Ann Alexander Data Structures.

Slides:



Advertisements
Similar presentations
INFIX, PREFIX, & POSTFIX EXPRESSIONS. Infix Notation We usually write algebraic expressions like this: a + b This is called infix notation, because the.
Advertisements

Stacks & Their Applications COP Stacks  A stack is a data structure that stores information arranged like a stack.  We have seen stacks before.
Prefix, Postfix, Infix Notation
COSC 2006 Chapter 7 Stacks III
Stacks Example: Stack of plates in cafeteria.
Joseph Lindo Abstract Data Types Sir Joseph Lindo University of the Cordilleras.
C o n f i d e n t i a l Developed By Nitendra NextHome Subject Name: Data Structure Using C Title : Overview of Stack.
Chapter 3 Stacks.
Stacks Chapter 5. Chapter 5: Stacks2 Chapter Objectives To learn about the stack data type and how to use its four methods: push, pop, peek, and empty.
Infix to postfix conversion Process the tokens from a vector infixVect of tokens (strings) of an infix expression one by one When the token is an operand.
Reverse Polish Expressions Some general observations about what they are and how they relate to infix expressions. These 9 slides provide details about.
30-Jun-15 Stacks. What is a stack? A stack is a Last In, First Out (LIFO) data structure Anything added to the stack goes on the “top” of the stack Anything.
Stacks CS-240 & CS-341 Dick Steflik. Stacks Last In, First Out operation - LIFO As items are added they are chronologically ordered, items are removed.
Main Index Contents 11 Main Index Contents Stacks Further Stack Examples Further Stack Examples Pushing/Popping a Stack Pushing/Popping a Stack Class StackClass.
More About Stacks: Stack Applications Dan Nguyen CS 146, Spring 2004 Professor Sin-Min Lee.
The Stack and Queue Types Lecture 10 Hartmut Kaiser
Stack  A stack is a linear data structure or abstract data type for collection of items, with the restriction that items can be added one at a time and.
Stack Data Structure By : Imam M Shofi. What is stack? A stack is a limited version of an array. A stack is a limited version of an array. New elements,
Data Structures: CSCI 362 – Stack Implementation Data Structures: CSCI 362 – Stack Implementation lecture notes adapted from Data Structures with C++ using.
Stack Applications.
Week7 Stack Data Structures & Algorithms. Introduction to Stacks and Queues Widely used data structures Ordered List of element Easy to implement Easy.
CSC 205 Programming II Postfix Expressions. Recap: Stack Stack features Orderly linear structure Access from one side only – top item Stack operations.
Review 1 Introduction Representation of Linear Array In Memory Operations on linear Arrays Traverse Insert Delete Example.
Chapter 4 Stacks Stacks A stack is a linear data structure that can be accessed only at one of its ends for storing and retrieving. Its called.
Computer Science Department Data Structure & Algorithms Problem Solving with Stack.
SAK 3117 Data Structures Chapter 3: STACKS. Objective To introduce: Stack concepts Stack operations Stack applications CONTENT 3.1 Introduction 3.2 Stack.
Data Structures. The Stack: Definition A stack is an ordered collection of items into which new items may be inserted and from which items may be deleted.
 STACK STACK  BASIC STACK OPERATIONS BASIC STACK OPERATIONS  PUSH ALGORITHM PUSH ALGORITHM  POP ALGORITHM POP ALGORITHM  EVALUATING A POSTFIX EXPRESSION.
EC-211 DATA STRUCTURES LECTURE 8. STACK APPLICATIONS Infix, Prefix, and Postfix Expressions Example – Infix: A+B – Prefix: +AB – Postfix: AB+
CHAPTER 3 STACK CSEB324 DATA STRUCTURES & ALGORITHM.
Basic Data Structures Stacks. A collection of objects Objects can be inserted into or removed from the collection at one end (top) First-in-last-out.
CHP-3 STACKS.
Reverse Polish Notation Written by J.J. Shepherd.
Prefix, Postfix, Infix Notation. Infix Notation  To add A, B, we write A+B  To multiply A, B, we write A*B  The operators ('+' and '*') go in between.
Stacks A stack is a linear data structure that can be accessed only at one of its ends for storing and retrieving data LIFO (Last In First Out) structure.
Stacks Chapter 5 © 2015 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Data Structures and Abstractions with Java, 4e Frank Carrano.
DATA STRUCTURES Application of Stack – Infix to Postfix conversion a Joshua Presentation.
Prof. I. J. Chung Data Structure #5 Professor I. J. Chung.
1 Data Structures and Algorithms Stack. 2 The Stack ADT Introduction to the Stack data structure Designing a Stack class using dynamic arrays Linked Stacks.
CC 215 DATA STRUCTURES MORE ABOUT STACK APPLICATIONS Dr. Manal Helal - Fall 2014 Lecture 6 AASTMT Engineering and Technology College 1.
Applications of Stack Maitrayee Mukerji. Stacks Last In First Out (LIFO List) ◦ FILO? Insertions and Deletions from the same end called the Top Push(),
1 Data Structures and Algorithms Stack. 2 The Stack ADT Introduction to the Stack data structure Designing a Stack class using dynamic arrays Linked Stacks.
Review Use of Stack Introduction Stack in our life Stack Operations
Data Structure By Amee Trivedi.
Stacks Chapter 5.
Infix to postfix conversion
MEMORY REPRESENTATION OF STACKS
Objectives In this lesson, you will learn to: Define stacks
Copyright ©2012 by Pearson Education, Inc. All rights reserved
STACKS.
Stack application: postponing data usage
Algorithms and Data Structures
Visit for more Learning Resources
PART II STACK APPLICATIONS
COMPUTER 2430 Object Oriented Programming and Data Structures I
Stacks Chapter 5 Adapted from Pearson Education, Inc.
STACK By:- Rajendra ShakyawalP.G.T. Computer Science KV-No.1, AFS, Tambaram, Chennai.
Stacks, Queues, and Deques
More About Stacks: Stack Applications
Infix to Postfix Conversion
Stack A data structure in which elements are inserted and removed only at one end (called the top). Enforces Last-In-First-Out (LIFO) Uses of Stacks Evaluating.
COMPUTER 2430 Object Oriented Programming and Data Structures I
Infix to Postfix Conversion
More About Stacks: Stack Applications
17CS1102 DATA STRUCTURES © 2016 KL University – The contents of this presentation are an intellectual and copyrighted property of KL University. ALL RIGHTS.
Chapter 7 (continued) © 2011 Pearson Addison-Wesley. All rights reserved.
Presented by : Aman Gupta PGT CS KV No.1, Narimedu, Madurai
DATA STRUCTURES IN PYTHON
Stacks A stack is an ordered set of elements, for which only the last element placed into the stack is accessible. The stack data type is also known as.
© 2016 Pearson Education, Ltd. All rights reserved.
Presentation transcript:

STACK CHAPTER 03 Developed By :- Misha Ann Alexander Data Structures

Stack Stacks are linear lists. All deletions and insertions occur at one end of the stack known as the TOP. Data going into the stack first, leaves out last. Stacks are also known as LIFO data structures (Last-In, First-Out). Developed By :- Misha Ann Alexander Data Structures

Stack Developed By :- Misha Ann Alexander Data Structures

OPERATIONS ON THE STACK push – Adds an item to the top of a stack. pop – Removes an item from the top of the stack and returns it to the user. Developed By :- Misha Ann Alexander Data Structures

STACK DATA :- 10,20,30,40,50,60 PUSH 10 PUSH 20 PUSH 30 PUSH 40 ….. 40 TOP 30 TOP 20 TOP 10 TOP Developed By :- Misha Ann Alexander Data Structures

STACK OPERATIONS POPPED ELEMENTS 40 30 20 40 TOP 30 TOP 20 TOP 10 Developed By :- Misha Ann Alexander Data Structures

APPLICATIONS OF STACK INFIX TO POSTFIX CONVERSION INFIX TO PREFIX CONVERSION STRING REVERSE EVALUATION OF POSTFIX EXPRESSION CHECK WHETHER THE EXPRESSION IS VALID OR NOT Developed By :- Misha Ann Alexander Data Structures

INFIX TO POSTFIX CONVERSION EXPRESSIONS Prefix: + a b Infix: a + b Postfix: a b + Developed By :- Misha Ann Alexander Data Structures

Infix to Postfix Conversion There are two methods ---- Manual method(Parenthesis) ----- stack method Developed By :- Misha Ann Alexander Data Structures

Manual Method(Infix to Postfix) A+b *d/e A+(b *d)/e A+((b *d)/e) ( A + ( ( b * d )/e ) ) ABD*E/+ Developed By :- Misha Ann Alexander Data Structures

Manual Method(Infix to Prefix) A+b *d/e A+(b *d)/e A+((b *d)/e) ( A + ( ( b * d )/e ) ) +A/*BDE Developed By :- Misha Ann Alexander Data Structures

Infix to Postfix using stack A + B * C - D / E Infix Stack(bot->top) Postfix a) A + B * C - D / E b) + B * C - D / E A c) B * C - D / E + A d) * C - D / E + A B e) C - D / E + * A B f) - D / E + * A B C g) D / E + - A B C * h) / E + - A B C * D i) E + - / A B C * D j) + - / A B C * D E k) A B C * D E / - + Developed By :- Misha Ann Alexander Data Structures

Infix to Prefix using stack Reverse the infix string . Replace ‘(‘ with ‘)’ and ‘)’ with ‘(‘. Convert it to postfix. Reverse the result. Developed By :- Misha Ann Alexander Data Structures

Postfix evaluation Operand: push Operator: pop 2 operands, do the math, pop result back onto stack 1 2 3 + * Postfix Stack( bot -> top ) 2 3 + * 1 3 + * 1 2 + * 1 2 3 * 1 5 // 5 from 2 + 3 5 // 5 from 1 * 5 Developed By :- Misha Ann Alexander Data Structures