99999999999999 #include #include struct node { struct node *prev; struct node *next; int data; }; struct node *start=NULL; void traverse(); int main(void) { int n,i,item; struct node *ptr,*temp; printf("Enter how many nodes:"); scanf("%d", &n); for(i=0;idata=item; if(start==NULL) { ptr->next=NULL; ptr->prev=NULL; start=ptr; } else { temp=start; while(temp->next!=NULL) { temp=temp->next; } temp->next=ptr; ptr->prev=temp; ptr->next=NULL; } } printf("Printing values in forward direction..............\n"); ptr=start; while(ptr!=NULL) { printf("%d->",ptr->data); ptr=ptr->next; } ptr=start; while(ptr->next!=NULL) { ptr=ptr->next; } printf("\nPrinting values backward direction...\n"); while(ptr!=NULL) { printf("%d->",ptr->data); ptr=ptr->prev; } return 0; } 10 #include #define maxsize 50 int stack[maxsize],top=-1; void create(); void display(); void pop(); void push(); int main() { int ch,top=-1; while(1) { printf("\n1.Create\n"); printf("2.Display\n"); printf("3.Push\n"); printf("4.Pop\n"); printf("5.Exit\n"); printf("Enter your choice:"); scanf("%d",&ch); if(ch==5) { return 0; } switch(ch) { case 1: create(); break; case 2: display(); break; case 3: push(); break; case 4: pop(); break; } } } void create() { int che; do { top++; printf("Input element:"); scanf("%d",&stack[top]); printf("Press 1 if more data other wise 0:"); scanf("%d",&che); }while(che==1); return; } void display() { int i; if(top==-1) { printf("Stack is empty"); } for(i=top;i>=0;i--) { printf("%d\t",stack[i]); } return; } void push() { int m; if(top==maxsize-1) { printf("Overflow"); return; } top++; printf("Enter new element:"); scanf("%d",&m); stack[top]=m; return; } void pop() { if(top==-1) { printf("Underflow"); return; } printf("%d is deleted",stack[top]); stack[top]='\0'; top--; return; } 1111111111111111111111111 #include #define maxsize 50 int stack[maxsize],top=1; void create(); void display(); void pop(); void push(); int main() { int ch,top=1; while(1) { printf("\n1.create\n"); printf("2.display\n"); printf("3.push\n"); printf("4.pop\n"); printf("5.exit\n"); printf("enter your choice:"); scanf("%d",&ch); if(ch==5) { return 0; } switch(ch) { case 1: create(); break; case 2: display(); break; case 3: push(); break; case 4: pop(); break; } } } void creator() { int che; do { top++; printf("input element:"); scanf("%d",&stack[top]); printf("press 1 if more data otherwise 0:"); scanf("%d",&che); } while(che==1); return; } void display() { int i; if(top==-1) { printf("stack is empty"); } for(i=top;1>=0;i--) { printf("%d\t",stack[i]); } return; } void push() { int m; if(top==maxsize-1) { printf("overflow"); return; } top++; printf("enter new element:"); scanf("%d",&m); stack[top]=m; return; } void pop() { if (top==-1) { printf("underflow"); return; } printf("%d is deleted",stack[top]); stack[top]='\0'; top--; return; } 122222222222222 #include #include int stack[20]; int top=-1; void push(int); int pop(); int main(void) { char exp[20],*e; int n1,n2,n3,num; printf("enter the postfix expression:"); scanf("%s",exp); e=exp; while(*e!='\0') { if(isdigit(*e)) { num=*e-48; push(num); } else { n1=pop(); n2=pop(); switch(*e) { case'+': n3=n1+n2; break; case'-': n3=n2-n1; break; case'*': n3=n2*n1; break; case'/': n3=n2/n1; break; } push(n3); } e++; } printf("result=%d",pop()); return 0; } void push(int x) { stack[++top]=x; } int pop() { return stack[top--]; } 133333333333 #include #define maxsize 50 int queue[maxsize],front=-1,rear=-1; void push(); void pop(); void display(); int main(void) { int ch,c=1; while(1) { printf("\n1.push"); printf("\n2.pop"); printf("\n3.display"); printf("\n4.exit"); printf("\n enter your choice:"); scanf("%d",&ch); if(ch==4) { return 0; } switch(ch) { case 1: push(); break; case 2: pop(); break; case 3: display(); break; } } return 0; } void push() { int a; printf("enter value:"); scanf("%d",&a); if(rear==maxsize-1); { printf("overflow"); return; } rear++; queue[rear]=a; if(front==-1) { front=0; } return; } void pop() { int a; if (front==-1) { printf("queue empty"); return; } printf("%d is deleted",queue[front]); a=queue[front]; queue[front]=0; if(front=rear=-1) { front=rear=-1; } else { front++; } return; } void display() { int t; if(front==-1) { printf("queue is empty"); } else { printf("queue elements are...\n"); for(t=front;t<=rear;t++) { printf("%d/t",queue[t]); } } return; }