Professional Documents
Culture Documents
21SCSE1040134 Stack in Array
21SCSE1040134 Stack in Array
DATA STRUCTURE
Ankit Chauhan
(21SCSE1040134)
Amit Kumar
(21SCSE1040072)
Ankur Kumar
(21SCSE1040080)
STACK DATA STRUCTURE
Definition
ref. on-
2
STACK DATA STRUCTURE
Operations on stack
85 63 5 15 10
85
TOP
ARRAY
63
5
15 We are given a stack of elements: 85,63,5,15,10.
10
STACK
4
* According to a Survey
Memory Representation of a STACK as an Linked-
list
5
Memory Representation of a STACK as an Linked-
list
6
Memory Representation of a STACK as an Linked-
list
7
CODE TO IMPLEMENT TWO STACK IN ONE
ARRAY
#include <stdio.h>
#include <stdlib.h>
#define MAXSIZE 10
struct stack
{
int stk[MAXSIZE];
int top;
int top2;
};
typedef struct stack STACK;
STACK s;
void push(void);
void push2(void);
int pop(void);
int pop2(void);
void display(void);
void display2(void);
8
CODE TO IMPLEMENT TWO STACK IN ONE
ARRAY
void main ()
{
int choice;
int option = 1;
s.top = -1;
s.top2 = MAXSIZE;
14
REAL LIFE EXAMPLE OF TWO STACK IN ONE
ARRAY
Consider a scenario where a little boy has a box, and boy divide the box into two half part to
store his new comic in it and another used to store his old comic books in it. And we know that
if we put something in the box to use when we remove the same goes out one by one.
The same thing also perform by stack, which is called as LIFO(Last in First Out) philosophy.
D
OL W
NE
IMAGE REF
BY-
15
THANK
YOU