SORTING USING SHELL SORT
SORTING USING SHELL SORT
BCA third semester
data structure
#include<stdio.h>
#include<conio.h>
int array;
void ShellSort(int *array, int n)
{
int i,j,iter, jter, increment, temp;
for(increment = n/2;increment > 0; increment /= 2)
{
for(i = increment; i<n; i++)
{
temp = array;
for(j = i; j >= increment...
SORTING USING QUICK SORT
SORTING USING QUICK SORT
BCA THird Semester
Data Structure
#include<stdio.h>
#include<conio.h>
#define max 10
int a, n, i, l, h;
void main()
{
void input(void);
input();
getch();
}
void input(void)
{
void quick_sort(int a, int l , int h);
void output(int a, int n);
clrscr();
printf("nnHow MAny Element to You Stored (Array...
SHORTING USING MERGE SORT
SHORTING USING MERGE SORT
DATA Structure
BCA Third Semester
#include<stdio.h>
#include<conio.h>
void merge(int ,int ,int ,int );
void break_a(int ,int ,int );
int main()
{
int arr;
int i,size;
clrscr();
printf("nt------- Merge sorting method -------nn");
printf("Enter total no. of elements : ");
scanf("%d",&size);
for(i=0; i<size; i++)
{
printf("Enter %d element :...
SORTING USING BUBBLE SORT
SORTING USING BUBBLE SORT
BCA Third semester
Data Structure
#include<stdio.h>
#include<conio.h>
void main()
{
int arr,i,j,temp;
clrscr();
for(i=0;i<5;i++)
{
printf("Enter elements");
scanf("%d",&arr);
}
for(i=0;i<5;i++)
{
for(j=i+1;j<5;j++)
{
if(arr > arr)
{
temp=arr;
arr=arr;
arr=temp;
}
}
}
for(i=0;i<5;i++)
{
printf(" %d ",arr);
}
getch();
}
OUTPUT
Enter Elements : 40
Enter Elements : 10
Enter Elements : 30
Enter Elements : 60
Enter Elements : 20
After Sorting :
10 20 30 40...
SORTING USING BINARY SEARCH TREE
SORTING USING BINARY SEARCH TREE
BCA THIRD semester
data structure
#include<stdio.h>
#include<conio.h>
#include<malloc.h>
struct node
{
int data;
struct node *right, *left;
};
struct node *nw, *root, *temp;
void creation(struct node *root, struct node *nw)
{
if(nw -> data < root-> data)
{
if(root -> left == NULL)
root -> left...
SEARCH ELEMENT FOR TREE
SEARCH ELEMENT FOR TREE
bca third semester
Data structure
#include<stdio.h>
#include<conio.h>
#include<malloc.h>
struct node
{
int data;
struct node *right, *left;
};
struct node *nw, *root, *temp;
int key,flag=0;
void creation(struct node *root, struct node *nw)
{
if(nw -> data < root-> data)
{
if(root -> left == NULL)
root -> left...
BINARY SEARCH TREE TAVERSAL
bca third semester
Binary Search tree taversal
program data structure
#include<stdio.h>
#include<conio.h>
#include<malloc.h>
struct node
{
int data;
struct node *right, *left;
};
struct node *nw, *root, *temp;
void creation(struct node *root, struct node *nw)
{
if(nw -> data < root-> data)
{
if(root -> left == NULL)
root -> left...
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...