diff --git a/Contributors.html b/Contributors.html index aaeaa80efc..e7cd12ee9e 100644 --- a/Contributors.html +++ b/Contributors.html @@ -1886,17 +1886,26 @@ "username": "https://github.com/dickytrianza" }, -{ + { "id": 347, "fullname": "Srinjoy Pati", "username": "https://github.com/srinjoy-26" }, + + + { + "id": 349, + "fullname": "Bhumit", + "username": "https://github.com/BhumitRohilla" + } + { - "id":349, + "id":350, "fullname": "d-coder111", "username": "https://github.com/d-coder111" }, + ]; diff --git a/Program's_Contributed_By_Contributors/Implementation_of_DS/BSTsort.c b/Program's_Contributed_By_Contributors/Implementation_of_DS/BSTsort.c new file mode 100644 index 0000000000..6ea067c4a2 --- /dev/null +++ b/Program's_Contributed_By_Contributors/Implementation_of_DS/BSTsort.c @@ -0,0 +1,106 @@ +//sorting using binary tree +#include +#include + +struct node{ + struct node *left; + int data; + struct node *right; +}; + +void insert(struct node *, int element); + +int * traversal(struct node *node ,int *sort, int *count); + +int main() +{ + unsigned int n; + printf("Enter elements you want to add in array: "); + scanf("%d", &n); + int arr[n]; + printf("Enter elements now: \n"); + + for(int i=0;ileft=NULL; + root->right=NULL; + root->data=arr[0]; + + + for(int i=1;idata){ + if(node->left==NULL){ + struct node *newNode; + newNode=(struct node *)malloc(sizeof(struct node)); + newNode->data=element; + newNode->left=NULL; + newNode->right=NULL; + + node->left=newNode; + } + else{ + insert(node->left, element); + } + } + else if(element>=node->data){ + if(node->right==NULL){ + struct node *newNode; + newNode=(struct node *)malloc(sizeof(struct node)); + newNode->data=element; + newNode->left=NULL; + newNode->right=NULL; + + node->right=newNode; + } + else{ + insert(node->right, element); + } + + } +} + + +int * traversal(struct node *node, int *sort, int *count){ + if(node!=NULL){ + sort=traversal(node->left, sort, count); + *(sort+ *count)=node->data; + (*count)++; + printf("\n"); + sort=traversal(node->right, sort, count); + + } + return sort; + +}