Download presentation
Presentation is loading. Please wait.
1
UNIT-II
3
Stack
6
Top 89 13 Top 13 9 9 9 Top Top 1. Empty stack Push Push Push 89 89 13 9 Top 13 9 9 Top Top Top 1. Pop Push Pop Empty Stack
9
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--]); }
10
Implementation using Array
int Is_empty() { if(top==-1) return 1; else return 0; } int Is_full() if(top==max-1) }; // class completion
16
Chess
26
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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.