IMPLEMENT EVALUATION OF POSTFIX
data structure programs
IMPLEMENT EVALUATION OF POSTFIX
bca third semester
#include<stdio.h>
#include<string.h>
int top = -1;
int stack;
void push (int data) {
stack = data;
}
int pop () {
int data;
if (top == -1)
return -1;
data = stack;
stack = 0;
top--;
return (data);
}
int main() {
char str;
int...
INFIX TO POSTFIX EXPRESSION
bca
infix to ppostfix expression
third semester
program
#include<stdio.h>
#include<math.h>
char inf,postf;
int st,i=0,j=0,top=-1;
void push(int);
char pop();
main()
{
clrscr();
st=0;
printf("Enter infix expression : ");
gets(inf);
while(inf!=NULL)
{
switch(inf)
{
case '(':
push(0);
break;
case '+':
while(st>=1)
{
postf=pop();
}
push(1);
break;
case '-':
while(st>=1)
{
postf=pop();
}
push(2);
break;
case '*':
while(st>=3)
{
postf=pop();
}
push(3);
break;
case '/':
while(st>=3)
{
postf=pop();
}
push(4);
break;
case '^':
while(st>=5)
{
postf=pop();
}
push(5);
break;
case ')':
while(st!=0)
postf=pop();
top--;
break;
default:
postf=inf;
}
i++;
}
while(top>-1)
{
postf=pop();
}
postf=NULL;
printf("Postfix expression : ");
puts(postf);
getch();
}
void push(int p)
{
st=p;
}
char pop()
{
int op;
op=st;
switch(op)
{
case 1:
return '+';
case 2:
return '-';
case 3:
return '*';
case 4:
return...
INFIX TO PREFIX CONVERSION
BCA Third semester
Infix to prefix conversion
Data Structure
#include<stdio.h>
#include<conio.h>
#include<malloc.h>
#define MAX 20
char stack;
int top = -1;
char pop();
void push(char item);
int prcd(char symbol) {
switch(symbol) {
case '+':
case '-':
return 2;
case '*':
case '/':
return 4;
case '^':
case '$':
return 6;
case '(':
case ')':
case '#':
return 1;
}
}
int isoperator(char...
ADDITON OF TWO POLYNOMIAL
BCA Third Semester
ADDITON OF TWO POLYNOMIAL
datastructure
#include<stdio.h>
#include<malloc.h>
#include<conio.h>
struct link{
int coeff;
int pow;
struct link *next;
};
struct link *poly1=NULL,*poly2=NULL,*poly=NULL;
void create(struct link *node)
{
char ch;
do
{
// clrscr();
printf("n Enter coeff : ");
scanf("%d",&node->coeff);
printf(" Enter power : ");
scanf("%d",&node->pow);
node->next=(struct link*)malloc(sizeof(struct link));
node=node->next;
node->next=NULL;
printf("n Continue(y/n):");
ch=getch();
}
while(ch=='y' || ch=='Y');
}
void show(struct link *node)
{
while(node->next!=NULL)
{
printf("%dx^%d",node->coeff,node->pow);
node=node->next;
if(node->next!=NULL)
printf("...
DOUBLY LINKED LIST
bca third semester
doubly linked list
data structure program
#include<stdio.h>
#include<conio.h>
#include<malloc.h>
int pos,i,n,item;
struct doubly
{
int data;
struct doubly *pre, *next;
}; struct doubly *head, *tail, *temp, *temp1, *temp2, *nw;
void insert_b()
{
int item;
clrscr();
printf("Enter Item : ");
scanf("%d",&item);
nw = (struct doubly *)malloc(sizeof(struct doubly));
nw -> data =...
SINGLY LINEAR LINK LIST
BCA Third Semester
Singly Linear link list
data structure
#include<stdio.h>
#include<conio.h>
#include<malloc.h>
struct link
{
int data;
struct link *next;
};struct link *nw, *head, *tail, *temp1, *temp2;
void insert_begin();
void insert_middle();
void insert_end();
void delete_begin();
void delete_middle();
void delete_end();
void display();
void main()
{
int item,ch;
do
{
clrscr();
printf("1. Insert Node of Beginning : n2. Insert Node...
QUEUE USING LINKED LIST
queue using linked list
BCA THird semester
Data Structure'
#include <stdlib.h>
struct node {
int data;
struct node *link;
};
struct node *temp,*front, *rear; /* Global Declarations */
void Insert(int);
int Delete();
void Display();
main() {
/* Main Program */
int opn, elem;
front = rear = NULL;
do {
clrscr();
printf("n1....
QUEUE IMPLEMENTATION (ALL OPERATION)
QUEUE IMPLEMENTATION (ALL OPERATION)
DaTA STRUCTURE
#include<conio.h>
#include<stdio.h>
#define N 5
int queue={0};
int rear=0,front=0;
void insert(void);
void del(void);
void disp(void);
void cre(void);
void main()
{
int user=0;
clrscr();
do
{
clrscr();
printf("nTHE SIZE OF QUEUE IS = %d",N);
printf("nn 1. INSERT A New Element");
printf("n 2. DELETE A First Element");
printf("n 3. DISPLAY A...
Data Structure some implement Program
Data structure is a particular way of storing and organizing information in a computer so that it can be retrieved and used most productively.
Data structures are important for the following reasons:
1. Data structures are used in almost every...
QUEUE IMPLEMENTATION USING ARRAY
QUEUE IMPLEMENTATION USING ARRAY
BCA third semester
DATA STRUCTURE
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#define max 5
int front=0,rear=-1;
int queue;
void main()
{
int ch,i;
while(1)
{
clrscr();
printf("1. Insertionn2. Deletionn3. Displayn4. ExitnnEnter your Choice : ");
scanf("%d",&ch);
switch(ch)
{
case 1:
clrscr();
if(rear == max-1)
printf("Queue Overflow !!!!");
else
{
rear++;
printf("Enter Element : ");
scanf("%d",&queue);
}
getch();
break;
case 2:
clrscr();
if(front>rear)
printf("Queue Underflow !!!!");
else
{
printf("%d is deletion...