Presentation is loading. Please wait.

Presentation is loading. Please wait.

UNIT-II.

Similar presentations


Presentation on theme: "UNIT-II."— Presentation transcript:

1 UNIT-II

2

3 Stack

4

5

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

7

8

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

11

12

13

14

15

16 Chess

17

18

19

20

21

22

23

24

25

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

27

28

29

30

31

32

33


Download ppt "UNIT-II."

Similar presentations


Ads by Google