Binary Search Tree in Data structure (Code Detail Explanation) Algorithm

preview_player
Показать описание
Binary Search Tree in data structure is explained in detail.Write an algorithm and program for BST ( Binary search tree).
Рекомендации по теме
Комментарии
Автор

I am watching your video at 4.30 A.M. Man!!! You are great!! Thank you so much dear sir. Please keep up the good work and thank you again :D

monafchowdhury
Автор

Best video I found for BST code... great way of teaching and explaining..thank you sir for providing such a easiest explanation.

poojakumawat
Автор

Great Explanation Sir. Your efforts are greatly appreciated. Keep rocking!

vishnuvardankp
Автор

Watch more than 10 videos but didn't understand them well
But by seeing this video my all doubt is clear 👍👍👍

shivam
Автор

Such a brilliant lecture... thanks sir

sahelimajumder
Автор

I am happy for know BST easily form this sir.

anindyasundarhazra
Автор

Thank you sir. It's very useful and cleared all Doubts.

aravindbalakrishnan
Автор

Thank you so much sir! You made things so clear and easy!
You are doing a great job!

ayeshaadhikari
Автор

create a playlist for the complete data structure. Your way of explanation is very good

chetanpatidar
Автор

Hats off to your patience and committment. Thanks for this great video. Could you please write a program in Java for the BST? C & C++ is hardly taught. May be you can compare the 2 program to highlight the differences between Java and C, c++. Thanks again for the wonderful video.

SSH
Автор

Thank you sir you made it look easy✌🏻✌🏻

azharahmad
Автор

Thank you sir ..!
Go ahead like this sir

anusrikamidri
Автор

I’ve been waiting for this. Thanks a lot. Will you do anything on B-Trees soon?

ErnestOlusanya
Автор

11:56 it can only be less than.... not equal to. Coz duplicates are not allowed in a BST

pi_by_
Автор

Hello Friends!! code krlo!!
jokes apart nice explanation :)

veerendra
Автор

Thankyou so much sir for easy explanation
Sir iska output 16 hi kyu aarha h pr

Krishnaguided
Автор

but u didn't said how to display those elements after inserrion

chandrachandu
Автор

Hi Vivekanand, Can you please explain the N-Queens problem?

svdfxd
Автор

sir, i have tried to code bst but is not woring can you help me out?
#include<stdio.h>
#include<stdlib.h>
struct node{
int data;
struct node *left;
struct node *right;
};
int search_bst(int n);
void preorder(struct node *ptr);
int search_bst_recursion(int n, struct node *ptr);
void insert(int n);
struct node *head = NULL;
struct node *ptr=head;
void append(){
struct node *temp=(struct node*)(malloc)(sizeof(struct node));
printf("\nEnter node data : ");
scanf("%d", &temp->data);
temp->left=NULL;
temp->right=NULL;
do{
if(head==NULL){
head=temp;
ptr=head; //if no node create first node
}
else if(temp->data>ptr->data){ //compare current node data with ptr(current node)
if(ptr->right!=NULL){ //(if it is not the last node)
ptr=ptr->right; //move it to next node
}
}
else{
if(temp->data<ptr->data){
if(ptr->left!=NULL){
ptr=ptr->left;
}
}
}
(ptr->right!=NULL)) || ((ptr->left!=NULL) && ptr->right!=NULL));//here is the confusion what to code in while
/*if curent data(temp->data)is less than ptr->data (parent data) but left node is not empty*/
if(temp->data<ptr->data){ //compersion of current node with previos(parent) node
ptr->left=temp;
}
else{
ptr->right=temp;
}
ptr=head; //to append the next node with head start from head
}
void preorder(struct node *ptr){
printf("%d\t", ptr->data);
if((ptr->left!=NULL && ptr->right!=NULL)){
if(ptr->left!=NULL)
preorder(ptr->left);
if(ptr->right!=NULL)
preorder(ptr->right);
}
}
int search_bst(int n){
struct node *ptr=head;
while(ptr){
if(n==ptr->data){
return 1;
}
else if(n<ptr->data){
ptr=ptr->left;
}
else {
ptr=ptr->right;
}
}
}
int search_bst_recursion(int n, struct node *ptr){
if(ptr->data==n){
return 1;
}
else if(n<ptr->data){
if(ptr->left!=NULL)
search_bst_recursion(n, ptr->left);
else
return 0;
}
else{
if(ptr->right!=NULL)
search_bst_recursion(n, ptr->right);
else
return 0;
}
}
void insert(int n){
int sresult=search_bst(n);
if(sresult==1){
printf("Element already exsists in bst");
}
else{
struct node *temp=(struct node*)(malloc(sizeof(struct node)));
temp->left=NULL;
temp->right=NULL;
temp->data=n;
struct node *previous=head;
struct node *next=head;
while(previous){

next=previous;


}
else{




}
}
}
if(temp->data>next->data){
next->right=temp;
}
else{
next->left=temp;
}
}
}
void insert_recursion(int n){

}
int main(){
int choice, no, i, r, n;
do{
printf("\n1.append");
printf("\n2.view preorder");
printf("\n3.searching");
printf("\n4.Insert");
printf("\n5.insert using recursing");
printf("\n6.search using recursion");
printf("\n7.exit");
printf("\nEnter your choice : ");
scanf("%d", &choice);
switch(choice){
case 1:
printf("Enter no of nodes to create : ");
scanf("%d", &no);
for(i=0;i<no;i++)
append();
break;
case 2:
preorder(head);
break;
case 3:
printf("Enter element to search");
scanf("%d", &n);
r=search_bst(n);
if(r==1)
printf("Found");
else
printf("Not found");
break;
case 4:
printf("Enter a element to insert : ");
scanf("%d", &n);
insert(n);
break;
case 5:
printf("Enter a element to insert : ");
scanf("%d", &n);
insert_recursion(n);
break;
case 6:
printf("Enter a element to search");
scanf("%d", &n);
search_bst_recursion(n, head);
break;
case 7:
exit(1);
}}while(choice!=7);
}

debanjanpanigrahi
Автор

Sir Please make video on ALV implementation in same way ..

samundarsingh