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

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

View Full Document Right Arrow Icon
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;
Background image of page 1

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

View Full DocumentRight Arrow Icon
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++)
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 06/12/2011.

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 Right Arrow Icon
Ask a homework question - tutors are online