UNIT-II.

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
Senem Kumova Metin Spring2009 STACKS AND QUEUES Chapter 10 in A Book on C.
Sample PMT online… Browse 1120/sumII05/PMT/2004_1/ 1120/sumII05/PMT/2004_1/
Data Structure (Part I) Stacks and Queues. Introduction to Stack An stack is a ordered list in which insertion and deletions are made at one end. –The.
ARRAY BASED STACK DATED: 30 TH AUG 2012 CLASS - XII.
Stacks  Standard operations: IsEmpty … return true iff stack is empty IsFull … return true iff stack has no remaining capacity Top … return top element.
Lecture 5 Sept 15 Goals: stacks Implementation of stack applications Postfix expression evaluation Convert infix to postfix.
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.
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.
Singly Linked Lists - Ed. 2, 3: Chapter 4 - Ed. 4.: Chapter 3.
Circular List Next field in the last node contains a pointer back to the first node rather than null pointer From any point in such a list it is possible.
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.
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,
Review 1 Introduction Representation of Linear Array In Memory Operations on linear Arrays Traverse Insert Delete Example.
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.
DATA STRUCTURES AND ALGORITHMS Lecture Notes 4 Prepared by İnanç TAHRALI.
Data Structures and Algorithms Stacks. Stacks are a special form of collection with LIFO semantics Two methods int push( Stack s, void *item ); - add.
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’
Lists, Stacks and Queues in C Yang Zhengwei CSCI2100B Data Structures Tutorial 4.
Object-Oriented Programming Simple Stack Implementation.
Lab 6 Stack ADT. OVERVIEW The stack is one example of a constrained linear data structure. In a stack, the elements are ordered from most recently added.
Copyright © Curt Hill Stacks An Useful Abstract Data Type.
CS212: Object Oriented Analysis and Design Lecture 22: Generic Class Design.
Circular Linked List Singly Circular Linked List Doubly Circular Linked List.
STACK Data Structure
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.
Lecture No.05 Data Structures Dr. Sohail Aslam.  Josephus Problem #include "CList.cpp" void main(int argc, char *argv[]) { CList list; int i, N=10, M=3;
CSCE 3110 Data Structures & Algorithm Analysis
Chapter 4 Stacks
Stacks.
Stacks – review A Last-In First-Out (LIFO) structure Basic Operations:
CSCI 3333 Data Structures Stacks.
Sorted Linked List Same objective as a linked list, but it should be sorted Sorting can be custom according to the type of nodes Offers speedups over non-sorted.
Lecture No.06 Data Structures Dr. Sohail Aslam
Stacks.
Stack and Queue APURBO DATTA.
Stack.
CSCE 3110 Data Structures & Algorithm Analysis
Stack and Queue.
COMPUTER 2430 Object Oriented Programming and Data Structures I
CMSC 341 Lecture 5 Stacks, Queues
Stacks – review A Last-In First-Out (LIFO) structure Basic Operations:
CSCE 3110 Data Structures & Algorithm Analysis
Stacks Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Stacks.
Instructor: Mr.Vahidipour
Stack and Queues Stack implementation using Array
ADT list.
Introduction to Programming
CSC 143 Stacks [Chapter 6].
COMPUTER 2430 Object Oriented Programming and Data Structures I
Stacks and Queues 1.
Mutable Data (define mylist (list 1 2 3)) (bind ((new (list 4)))
Abstract Data Type Abstract Data Type as a design tool
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.
LAB#3 Stacks Nora Albabtin nora albabtin.
Stacks.
17CS1102 DATA STRUCTURES © 2016 KL University – The contents of this presentation are an intellectual and copyrighted property of KL University. ALL RIGHTS.
22C:21 Discrete Structures
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
Abstract Data Types Stacks CSCI 240
Presentation transcript:

UNIT-II

Stack

Top 89 13 Top 13 9 9 9 Top Top 1. Empty stack 2. Push 9 3. Push 13 4. Push 89 89 13 9 Top 13 9 9 Top Top Top 1. Pop 89 2. Push 13 3. Pop 9 4. Empty Stack

Implementation using Array #define max= 10 Class Stack { int data[max]; Data member int Top; Public: void initialize() { top=-1;} void push(int val) { data[++Top]=val; } int pop() { return (data[top--]); }

Implementation using Array int Is_empty() { if(top==-1) return 1; else return 0; } int Is_full() if(top==max-1) }; // class completion

Chess

void insert (int val) //INSERT FUNCTION { if (empty()) R=F=0; data[R]=val; } else { if (R==max-1) cout<<"sorry no space"; else { R++; data[R]=val; } }; class Q //CLASS IS DEFINED { int data[10]; int R,F; public: Q() R=F=-1; } int empty() //EMPTY FUNCTION if(R==-1) return 1; return 0; int delet() //delete function int P=data[F]; if(F==R) else F++; return P; 12 13 45 24 R F