Breaking News
You are here: Home / Tag Archives: Datastructure

Tag Archives: Datastructure

Feed Subscription

programm to impliment stack operation

programm to impliment stack operation

// PRO-1.PROGRAMM TO IMPLIMENT STACK OPERATION #include<stdio.h> #define size 5 int top=-1,a[size]; void main() { clrscr(); menu(); getch(); } void push() { if(top>=size-1) printf("\nStack is overflow\n"); else { top++; printf("\nEnter element you want to push..?"); scanf("\n%d",&a[top]); } } void pop() { if(top<0) printf("\nStack is empty\n"); else { printf("\n%d element is poped\n",a[top]); top--; } } void disp() { int i; if(top<=-1) ... Read More »

programme to evaluate postfix espression

programme to evaluate postfix espression

#include<stdio.h> #include<conio.h> #define max 10 float s[max]; int top=-1; char *post; void main() { char ch; int i; float op1,op2,result; void push(float); float pop(void); clrscr(); printf ("\n Enter postfix notation:- "); gets(post); puts(post); for (i=0;post[i]!='\0';i++) { ch=post[i]; if (ch=='+'||ch=='-'||ch=='*'||ch=='/') { op2=pop(); op1=pop(); switch(ch) { case '+': result =op1+op2; break; case '-': result = op1 - op2; break; case '*': result ... Read More »

programm to evaluate prefix expresion

programm to evaluate prefix expresion

#include<stdio.h> #include<conio.h> int top = -1,item; void main() { int stack[100],a,b,max,ch,i,j=0; char p[100]; clrscr(); printf("\n Enter Prefix Equation:- "); gets(p); max = strlen(p); p[max]=')'; max++; p[max]='\0'; max=strlen(p); for(i=max-1 ; i>=0 ;i--) { //for operand. if(p[i]!='*' && p[i]!='/' && p[i]!='+' &&p[i]!='-' &&p[i]!=')') { printf("\n Enter the value:- "); scanf("%d",& item); push(stack,max-1); } if(p[i]=='*'|| p[i]=='+'||p[i]=='-'||p[i]=='/') { pop(stack,max-1); a= item; pop(stack,max-1); b=item; switch ... Read More »

program to convert infix exp.to postfix exp.

program to convert infix exp.to postfix exp.

#include<stdio.h> #include<conio.h> int top; char item; void main() { char stack[100],q[100],p[100]; int max,i,j=0; int ch; clrscr(); top=-1; printf("\n Enter infix equation:-"); gets(q); max=strlen(q); q[max]=')'; max++; q[max]='\0'; max=strlen(q); item='('; push(stack,max-1); printf("\n"); for (i=0;i<max;i++) { //for oprand. if((q[i]>=65 && q[i]<=92 || q[i]>=97 && q[i]<=122)) { p[j]=q[i]; j++; } //for left bracket. if(q[i]=='(') { item='('; push(stack,max-1); } //for operators. if(q[i]=='*'||q[i]=='/'||q[i]=='+'||q[i]=='-') { while(q[i]=='+'||q[i]=='-') { ... Read More »

program to convert infix exp.to prefix exp.

program to convert infix exp.to prefix exp.

#include<stdio.h> #include<conio.h> #include<string.h> # define n 25 int s[n]; int top=-1; void main() { char infix[80],prefix[80]; int i,j=0,l; clrscr(); printf("\nEnter infix expression:-"); gets(infix); l=strlen(infix); strrev(infix); for(i=0;i<l;i++) { switch(infix[i]) { case ')': push(infix[i]); break; case '^': push(infix[i]); break; case '*': case '/': while(s[top]=='^') prefix[j++]=pop(); push(infix[i]); break; case '+': case '-': while(s[top] == '^'||s[top]=='*'||s[top]=='/') prefix[j++]=pop(); push(infix[i]); break; case '(': while(s[top] !=')') prefix[j++]=pop(); ... Read More »

prog. to perform insertion & deletion operation on queue.

prog. to perform insertion & deletion operation on queue.

#define s 5 int f=-1,r=-1,q[s]; void main() { clrscr(); menu(); getch(); } void inst() { if(f==-1) f++; if(r==s-1) printf("\n\nQueue is full."); else { r++; printf("\nEnter a value..?"); scanf("\n%d",&q[r]); } } void del() { if(r==-1) printf("\n\nQueue is empty."); else f++; if(f==r) { f=-1;r=-1; } } void disp() { int i; if(r==-1) printf("\n\nQueue is empty."); else { for(i=f;i<=r;i++) printf("%4d",q[i]); } } menu() ... Read More »

prog.to insertion & deletion operation on cicular queue

prog.to insertion & deletion operation on cicular queue

#define s 5 int f=-1,r=-1,q[s]; void main() { clrscr(); menu(); getch(); } void inst() { if((r==s-1&&f==0)||r==f-1) printf("\n\nQueue is full."); else { if(r==s-1) r=0; else r++; printf("\nEnter a value..?"); scanf("\n%d",&q[r]); } if(f==-1) f++; } void del() { if(f==r) { f=-1;r=-1; } if(r==-1) printf("\n\nQueue is empty."); else { if(f==s-1) f=0; else f++; } } void disp() { int i; if(r==-1) printf("\n\nQueue is ... Read More »

prog.to perform insertion & deletion operation on dequeue.

prog.to perform insertion & deletion operation on dequeue.

#define s 5 int f=-1,r=s,q[s]; void main() { clrscr(); menu(); getch(); } void inst_left() { if(f==r-1) printf("\n\nQueue is full."); else { f++; printf("\nEnter a value..?"); scanf("\n%d",&q[f]); } } void inst_right() { if(r==f+1) printf("\n\nQueue is full."); else { r--; printf("\nEnter a value..?"); scanf("\n%d",&q[r]); } } void del_left() { if(f==-1) printf("\n\nQueue is empty."); else f--; } void del_right() { if(r==s) printf("\n\nQueue is ... Read More »

prog.to perform insertion & deletion operation on priority queue.

prog.to perform insertion & deletion operation on priority queue.

#define s 10 int f1=0,r1=-1,f2=5,r2=4,q[s]; void main() { clrscr(); menu(); getch(); } void inst() { int p; printf("\nEnter priority(1/2)..?"); scanf("\n%d",&p); switch(p) { case 1: if(r1==4) printf("\nQueue is full."); else { r1++; printf("\nEnter element..?"); scanf("\n%d",&q[r1]); } break; case 2: if(r2==9) printf("\nQueue is full."); else { r2++; printf("\nEnter element..?"); scanf("\n%d",&q[r2]); } break; } } void del() { int p; printf("\nEnter priority(1/2)..?"); scanf("\n%d",&p); ... Read More »

single link list

single link list

#include<stdio.h> #define m (struct stud*)malloc(sizeof(struct stud)) struct stud { int roll; struct stud *next; }*first=NULL,*last,*a,*t,*p,*q; void main() { clrscr(); create(); menu(); getch(); } create() { char ans='y'; while(ans=='y') { a=m; a->next=NULL; printf("\n\nEnter roll no..?"); scanf("\n%d",&a->roll); if(first==NULL) first=a; else last->next=a; last=a; printf("\n\nWant to continue..?"); scanf("\n%c",&ans); } } void inst_frst() { a=m; printf("\nEnter roll no..?"); scanf("\n%d",&a->roll); a->next=first; first=a; } void inst_last() { ... Read More »

Scroll To Top