STACK Data Structure www.btechsmartclass.com.

Slides:



Advertisements
Similar presentations
STACKS & QUEUES. Stacks Abstract data types An abstract data type (ADT) is an abstraction of a data structure An ADT specifies : –Data stored –Operations.
Advertisements

Stacks, Queues, and Linked Lists
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.
1 Stack and Queue. 2 Stack In Out ABCCB Data structure with Last-In First-Out (LIFO) behavior.
Stacks  Standard operations: IsEmpty … return true iff stack is empty IsFull … return true iff stack has no remaining capacity Top … return top element.
Chapter 3 Stacks.
Data Structures & Algorithms
Stacks. What is a stack? Last-in first-out data structure (LIFO) New objects are placed on top Removal restricted to top object Examples?
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.
Lecture 6 Feb 12 Goals: stacks Implementation of stack applications Postfix expression evaluation Convert infix to postfix.
Stacks.
Chapter 12 C Data Structures Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 12 – Data Structures Outline 12.1Introduction.
Implementing Stacks Using Arrays CSC 1401: Introduction to Programming with Java Week 14 – Lecture 1 Wanda M. Kunkle.
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  Standard operations: IsEmpty … return true iff stack is empty Top … return top element of stack Push … add an element to the top of the stack.
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.
Microsoft® Small Basic
Ali Abdul Karem Habib Kufa University / mathematics & Science Of Computer.
Digital Electronics Data Structures LISP
Microsoft® Small Basic Stacks and Arrays Estimated time to complete this lesson: 1 hour.
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,
Week7 Stack Data Structures & Algorithms. Introduction to Stacks and Queues Widely used data structures Ordered List of element Easy to implement Easy.
Stacks and queues Basic operations Implementation of stacks and queues Stack and Queue in java.util Data Structures and Algorithms in Java, Third EditionCh04.
Review 1 Introduction Representation of Linear Array In Memory Operations on linear Arrays Traverse Insert Delete Example.
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.
Stack. Abstract Data Types (ADTs) An abstract data type (ADT) is an abstraction of a data structure An ADT specifies: Data stored Operations on the data.
 STACK STACK  BASIC STACK OPERATIONS BASIC STACK OPERATIONS  PUSH ALGORITHM PUSH ALGORITHM  POP ALGORITHM POP ALGORITHM  EVALUATING A POSTFIX EXPRESSION.
Cosc237/data structures1 Data Types Every data type has two characteristics: 1.Domain - set of all possible values 2.set of allowable operations Built-in.
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’
1 Stacks and Queues Based on D.S. Malik, Java Programming: Program Design Including Data Structures.
Stacks and Queues Based on D.S. Malik, Java Programming: Program Design Including Data Structures.
EASTERN MEDITERRANEAN UNIVERSITY Stacks EENG212 –Algorithms and Data Structures.
Data Structures Stack Namiq Sultan 1. Data Structure Definition: Data structures is a study of different methods of organizing the data and possible operations.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 18: Stacks and Queues.
Introduction Queue is a linear Data Structure in which the operations are performed based on FIFO (First In First Out) principle.
Stacks Nour El-Kadri CSI Stacks Software stacks are abstract data types (structures) similar to physical stacks, Plates Trays Books PEZ dispenser.
Data Structures. Abstract Data Type A collection of related data is known as an abstract data type (ADT) Data Structure = ADT + Collection of functions.
Linear Data Structures
Computer Engineering Rabie A. Ramadan Lecture 6.
Basic Data Structures (Stacks). 2 Basic Data Structures Stacks Queues Lists.
Stack Data Structure By Marwa M. A. Elfattah. Stack - What A stack is one of the most important non- primitive linear data structure in computer science.
COSC 2P03 Week 21 Stacks – review A Last-In First-Out (LIFO) structure Basic Operations: –push : insert data item onto top of stack –pop : remove data.
M180: Data Structures & Algorithms in Java Stacks Arab Open University 1.
Stacks. What is a Stack? A stack is a type of data structure (a way of organizing and sorting data so that it can be used efficiently). To be specific,
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
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.
 In general, Queue is line of person waiting for their turn at some service counter like ticket window at cinema hall, at bus stand or at railway station.
CSCE 3110 Data Structures & Algorithm Analysis
Stacks and Queues Chapter 4.
Chapter 15 Lists Objectives
Stacks.
Stacks.
STACK CHAPTER 03 Developed By :- Misha Ann Alexander Data Structures.
Visit for more Learning Resources
CSCE 3110 Data Structures & Algorithm Analysis
CSCE 3110 Data Structures & Algorithm Analysis
Stacks Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
STACK By:- Rajendra ShakyawalP.G.T. Computer Science KV-No.1, AFS, Tambaram, Chennai.
Cs212: Data Structures Computer Science Department Lab 7: Stacks.
Stacks: Implemented using Linked Lists
Mutable Data (define mylist (list 1 2 3)) (bind ((new (list 4)))
Abstract Data Type Abstract Data Type as a design tool
UNIT-II.
Stacks LIFO C C B B B B A A A A A Push (A) Push (B) Push (C) Pop Pop.
Stacks and Queues Based on D.S. Malik, Java Programming: Program Design Including Data Structures.
LAB#3 Stacks Nora Albabtin nora albabtin.
Stacks.
Abstract Data Types Stacks CSCI 240
Presentation transcript:

STACK Data Structure www.btechsmartclass.com

A stack is a ordered list of elements of same data type What is a STACK ? A stack is a container of elements that are inserted and removed according to the last-in first-out (LIFO) principle. A stack is a ordered list of elements of same data type A stack is a Linear list

What is a STACK ? In a stack all operation like insertion and deletion are performed at only one end called Top 1 2 3 4

What is a STACK ? Insertion Deletion In a stack all operation like insertion and deletion are performed at only one end called Top 4 Top 3 2 1

Operations on STACK ? Creation Insertion Deletion Displaying

Operations on STACK ? Creation Insertion Deletion Displaying 4 #define SIZE 5   int stack[SIZE]; Creation 3 Insertion 2 Deletion 1 Displaying stack

Operations on STACK ? Creation Insertion Deletion Displaying 4 3 2 1 Insertion operation is called as “push” 4 void push(element){ if(Stack is full) { printf(“FULL!!!”); } else Top++; stack[Top] = element; Creation 3 Insertion 2 Deletion 1 Displaying stack

Operations on STACK ? Creation Insertion Deletion Displaying 4 3 2 1 Deletion operation is called as “pop” 4 int pop( ){ if(Stack is Empty) { printf(“EMPTY!!!”); return Top; } else deleted = stack[Top]; Top--; return deleted; Creation 3 Insertion 2 Deletion 1 Displaying stack

Operations on STACK ? Creation Insertion Deletion Displaying 4 3 2 1 void display( ){ if(Stack is Empty) { printf(“EMPTY!!!”); } else for(i=Top; i>-1; i--) printf(“%d\n”,stack[i]); Creation 3 Insertion 2 Deletion 1 Displaying stack