STACK By:- Rajendra ShakyawalP.G.T. Computer Science KV-No.1, AFS, Tambaram, Chennai.

Slides:



Advertisements
Similar presentations
Lecture Stacks. A stack is a Last-In-First-Out (LIFO) or a First-In-Last-Out (FILO) abstract data type E.g. a deck of cards in which cards may be added.
Advertisements

CS 206 Introduction to Computer Science II 03 / 04 / 2009 Instructor: Michael Eckmann.
Stacks Chapter 5. Chapter Objectives  To learn about the stack data type and how to use its four methods: push, pop, peek, and empty  To understand.
Stacks CS-240 Dick Steflik. Stacks Last In, First Out operation - LIFO As items are added they are chronologically ordered, items are removed in reverse.
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.
CS 206 Introduction to Computer Science II 03 / 06 / 2009 Instructor: Michael Eckmann.
Reverse Polish Expressions Some general observations about what they are and how they relate to infix expressions. These 9 slides provide details about.
CS 206 Introduction to Computer Science II 10 / 15 / 2008 Instructor: Michael Eckmann.
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.
1 Stack Data : a collection of homogeneous elements arranged in a sequence. Only the first element may be accessed Main Operations: Push : insert an element.
Algorithms and Data Structures Representing Sequences by Arrays and Linked Lists.
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.
Chapter 7 Stack. Overview ● The stack data structure uses an underlying linear storage organization.  The stack is one of the most ubiquitous data structures.
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,
1 Stacks – Chapter 3 A stack is a data structure in which all insertions and deletions of entries are made at one end, called the top of the stack. Alternatively,
Week7 Stack Data Structures & Algorithms. Introduction to Stacks and Queues Widely used data structures Ordered List of element Easy to implement Easy.
Stacks. An alternative storage structure for collections of entities is a stack. A stack is a simplified form of a linked list in which all insertions.
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.
Due: 2007/11/12. Problem 1 Rewrite function Push and Pop (Program 3.10 and 3.12) using an additional variable lastOp as discussed on Page 146. The queue.
Data Structures (part 2). Stacks An Everyday Example Your boss keeps bringing you important items to deal with and keeps saying: “Put that last ‘rush’
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 18: Stacks and Queues (part 2)
Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix.
CHP-3 STACKS.
Computer Engineering Rabie A. Ramadan Lecture 6.
STACK Data Structure
Prof. I. J. Chung Data Structure #5 Professor I. J. Chung.
Chapter 3 Lists, Stacks, Queues. Abstract Data Types A set of items – Just items, not data types, nothing related to programming code A set of operations.
Stacks and Queues. DCS – SWC 2 Stacks A stack is an abstract data structure, with some special properties: –Insertion and deletion is only allowed at.
 Chapter 7 introduces the stack data type.  Several example applications of stacks are given in that chapter.  This presentation shows another use called.
Review Use of Stack Introduction Stack in our life Stack Operations
STACKS & QUEUES for CLASS XII ( C++).
Stacks Access is allowed only at one point of the structure, normally termed the top of the stack access to the most recently added item only Operations.
Data Structure By Amee Trivedi.
G64ADS Advanced Data Structures
Set Collection A Bag is a general collection class that implements the Collection interface. A Set is a collection that resembles a Bag with the provision.
Stacks Chapter 5.
Infix to postfix conversion
Chapter 15 Lists Objectives
MEMORY REPRESENTATION OF STACKS
Lecture No.06 Data Structures Dr. Sohail Aslam
Stack as an ADT.
Program to search an element of array using linear search.
Objectives In this lesson, you will learn to: Define stacks
Cinda Heeren / Geoffrey Tien
Stacks and Queues.
STACKS.
Algorithms and Data Structures
STACK CHAPTER 03 Developed By :- Misha Ann Alexander Data Structures.
Visit for more Learning Resources
Overview Introduction General Register Organization Stack Organization
Stacks, Queues, and Deques
Chapter 7 Stack.
Stack ADT Operations Application: Expression Evaluation
Stack and Queues Stack implementation using Array
Stacks and Queues.
CSE 214 – Computer Science II Stacks
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.
Stacks and Queues 1.
Stack Implementations
Stacks.
Topic 15 Implementing and Using Stacks
Jordi Cortadella and Jordi Petit Department of Computer Science
Stacks CS-240 Dick Steflik.
Stacks LIFO C C B B B B A A A A A Push (A) Push (B) Push (C) Pop Pop.
Stacks A list where insertions and deletions can occur only at the end of the list. linked list or array implementation topOfStack  operations:
Presented by : Aman Gupta PGT CS KV No.1, Narimedu, Madurai
Abstract Data Types Stacks CSCI 240
LINEAR DATA STRUCTURES
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.
Presentation transcript:

STACK By:- Rajendra ShakyawalP.G.T. Computer Science KV-No.1, AFS, Tambaram, Chennai

STACK Using Linked List What is Stack ? Operation on Stack … ( PUSH and POP) Applications of Stack

STACK A stack is a LIFO structure and physically it can be implemented as an array or as a linked list. A stack is implemented as an array that inherits all the properties of an array and if implemented as a linked list , all characteristics of a linked list are possessed by it. top S T A C K

OPERATIONS ON STACK A stack is generally implemented with two basic operations- Push and Pop. Whatever way a stack may be implemented, insertion (push) and deletions (POP) occur at the top only. Push – Allows adding an element at the top of the Stack. Pop - Allows to remove an element from the top of the Stack.

Stack Operations (PUSH , POP) Example top 6

Stack Operations (PUSH , POP) Example top 1 6

Stack Operations (PUSH , POP) Example 7 top 1 6

Stack Operations (PUSH , POP) Example 8 7 top 1 6

Stack Operations (PUSH , POP) Example 8 7 top 1 6

Stack Operations (PUSH , POP) Example 7 top 1 6

CREATING A STACK (LINKED STACK) The creation of a stack ( as a linked list) is the same as the creation of a linked list i.e., after getting a new node, TOP point to the newly inserted node.

Creating a Node for Stack struct stack { int info; stack *next; } *top, s; Info next S

INSERTION IN A LINKED STACK (PUSH) TOP Fig A 44 55 n TOP 33 44 55 n Fig B TOP 22 33 44 55 n Fig C As a push can only occur at the TOP gets modified every time. For instance, if we have a stack as shown in fig (a) after pushing 33 , it becomes as Fig (b). After pushing another element 22, it becomes as Fig (c).

DELETION (POP) FROM A LINKED STACK TOP 22 33 44 55 n Fig A TOP 33 44 55 n Fig B TOP 44 55 n Fig C Deletion i.e. popping also require modification of TOP i.e. TOP is made to point to the next node in the sequence. For instance, if the stack is shown in Fig a; after popping 22 , it becomes as Fig b. After Popping 33 , it becomes a Fig c.

Application of Stack Reversing a Line POLISH NOTATION CONVERSION OF INFIX EXPRESSION TO POSTFIX (SUFFIX) EXPRESSION

THANK YOU