{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

stackQueueprog

# stackQueueprog - Stacks and Queues implementation Code for...

This preview shows pages 1–3. Sign up to view the full content.

Stacks and Queues- implementation Code for manipulations of stacks and queues. Functions are provided for push, pop, enqueue and dequeue operations. The stack is indexed by stacktop, while the queue is being maintained by two indices – qfront and qback. #include <stdio.h> struct node{ int data; struct node *next; }; void push(struct node**stacktop,int d ); int pop(struct node**stacktop); void enqueue(struct node**qfront,int d , struct node**qback); int dequeue(struct node**qfront, struct node**qback); void main( ) { int num; int dd, ii; struct node* first = (struct node*) (malloc(sizeof(struct node))); struct node* front = (struct node*) (malloc(sizeof(struct node))); struct node* back = (struct node*) (malloc(sizeof(struct node))); front = NULL; back= NULL; first = NULL;

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
for (ii= 1; ii<=3; ii++) { printf("\n next number? ="); scanf("%d",&dd); push(&first,dd); } for (ii= 1; ii<=4; ii++) { dd = pop(&first); if (dd !=-999) printf("\n popped number =%d", dd); printf("\n\n"); } dd=0; for (ii= 1; ii<=4; ii++) { printf("\n give number for queue? ="); scanf("%d",&dd); enqueue(&front,dd,&back); printf("\n front value is %d",front->data); } for (ii= 1; ii<=5; ii++) {
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 5

stackQueueprog - Stacks and Queues implementation Code for...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online