"Binary Search Tree": A Micro-Project Report On
"Binary Search Tree": A Micro-Project Report On
Micro-Project Report
On
“Binary Search Tree”
Submitted By
Atharva Thakare (40)
Yash Dhumal (43)
Atharva Javnajal (45)
Under Guidance Of
Ms. Sheetal. K. Kawale
TECHNICAL EDUCATION
Certificate
This is to certify that Mr. Atharva Thakare Roll No. 40 of Semester III of Diploma in
Computer Technology of Institute STES’s Sou. Venutai Chavan Polytechnic (Code: 0040)
has completed the Micro Project satisfactorily in Subject Data Structures using ‘C’ (22317)
Program Code: CM
TECHNICAL EDUCATION
Certificate
This is to certify that Mr. Yash Dhumal Roll No. 43 of Semester III of Diploma in Computer
Technology of Institute STES’s Sou. Venutai Chavan Polytechnic (Code: 0040) has
completed the Micro Project satisfactorily in Subject Data Structures using ‘C’ (22317) for
Program Code: CM
TECHNICAL EDUCATION
Certificate
This is to certify that Mr. Atharva Javanjal Roll No. 45 of Semester III of Diploma in
Computer Technology of Institute STES’s Sou. Venutai Chavan Polytechnic (Code: 0040)
has completed the Micro Project satisfactorily in Subject Data Structures using ‘C’ (22317)
Program Code: CM
Annexure – I
Micro-Project Proposal
Annexure – II
Micro-Project Report
Binary Search Tree
1.0 Rationale:
A Binary Search Tree (BST), also called an ordered or sorted binary tree, is a rooted binary
tree whose internal nodes each store a key greater than all the keys in the node's left subtree
and less than those in its right subtree. A binary tree is a type of data structure for storing
data such as numbers in an organized way. Binary search trees allow binary search for fast
lookup, addition and removal of data items, and can be used to implement dynamic
sets and lookup tables.
/*
* C Program to Construct a Binary Search Tree and perform deletion, inorder
traversal on it
*/
#include <stdio.h>
#include <stdlib.h>
struct btnode
{
int value;
struct btnode *l;
struct btnode *r;
}*root = NULL, *temp = NULL, *t2, *t1;
void delete1();
void insert();
void delete();
void inorder(struct btnode *t);
void create();
void search(struct btnode *t);
void preorder(struct btnode *t);
void postorder(struct btnode *t);
void search1(struct btnode *t,int data);
int smallest(struct btnode *t);
int largest(struct btnode *t);
int flag = 1;
void main()
{
int ch;
printf("\nOPERATIONS ---");
printf("\n1 - Insert an element into tree\n");
printf("2 - Delete an element from the tree\n");
printf("3 - Inorder Traversal\n");
printf("4 - Preorder Traversal\n");
printf("5 - Postorder Traversal\n");
printf("6 - Exit\n");
while(1)
{
printf("\nEnter your choice : ");
scanf("%d", &ch);
switch (ch)
{
case 1:
insert();
break;
case 2:
delete();
break;
case 3:
inorder(root);
break;
case 4:
preorder(root);
break;
case 5:
postorder(root);
break;
case 6:
exit(0);
default :
printf("Wrong choice, Please enter correct choice ");
break;
}
}
}
/* To create a node */
void create()
{
int data;
scanf("%d", &data);
temp = (struct btnode *)malloc(1*sizeof(struct btnode));
temp->value = data;
temp->l = temp->r = NULL;
}
if (root == NULL)
{
printf("No elements in a tree to delete");
return;
}
printf("Enter the data to be deleted : ");
scanf("%d", &data);
t1 = root;
t2 = root;
search1(root, data);
}
}
else if ((data < t->value))
{
t1 = t;
search1(t->l, data);
}
else if ((data==t->value))
{
delete1(t);
}
}
/* To delete a node */
void delete1(struct btnode *t)
{
int k;
}
else
{
t1->r = t->l;
}
t = NULL;
free(t);
return;
}
7.2 Output:
10.0 Conclusion:
Thus, we developed a ‘Binary Search Tree’ using Data Structures.