Find min and max element in a binary search tree

  Рет қаралды 358,723

mycodeschool

mycodeschool

Күн бұрын

Пікірлер: 77
@dungnguyenhoanganh4188
@dungnguyenhoanganh4188 10 жыл бұрын
Although I was in Vietnam, I do not know much about English, but you preach is easy to understand . Easier to understand than the Vietnamese . Fantastic !! Thank you very much.
@mycodeschool
@mycodeschool 10 жыл бұрын
Dũng Nguyễn Hoàng Anh Love to Vietnam :)
@ntlzz93
@ntlzz93 9 жыл бұрын
Dũng Nguyễn Hoàng Anh me too.
@priyaravindran4337
@priyaravindran4337 4 жыл бұрын
SW Engineer for 7 years ...Computer Science graduate ...but understanding DSA concepts clearly now !! Thanks much !!
@sasaskvorc594
@sasaskvorc594 10 жыл бұрын
Thank you very much for your efforts. If i get a programer job thanks to this videos i will make a donation as soon as i can. You are way better than my profesors. Keep up the good work.
@mycodeschool
@mycodeschool 10 жыл бұрын
Saša Škvorc Thanks a lot and all the best to you :)
@aswin2pranav
@aswin2pranav 8 жыл бұрын
Doing the god's work really
@joycalcutta
@joycalcutta 7 жыл бұрын
:D - really funny dude!
@FarhanAli-km5id
@FarhanAli-km5id 4 жыл бұрын
I really really liked that video, because this tutorial provides"recursion method" as well as"Non recursion method" .. Thanks for that beautiful effort 💞.. from Pakistan...
@arunanshupadhi
@arunanshupadhi 10 жыл бұрын
Great tutorials dude.. could you please upload a video on finding permutations of a string in c?
@vandananayak9426
@vandananayak9426 2 жыл бұрын
I miss your videos sir. We all need a teacher like you. #respect
@newoap
@newoap 10 жыл бұрын
Superb tutorials. What about creating a video on deleting from a BST?
@mycodeschool
@mycodeschool 10 жыл бұрын
Owen Parkinson Yeah, I will create one on deleting node from BST. :)
@Gameplay-pq6hk
@Gameplay-pq6hk 8 жыл бұрын
please make videos for AVL TREE , THREADED ,B-TREE .
@wangchi562
@wangchi562 Жыл бұрын
Please come back sir, we need you
@prestoX
@prestoX 6 жыл бұрын
Thanks a ton Sir Kindly upload some videos on Balancing trees and AVL trees.
@ridershubham
@ridershubham 10 жыл бұрын
the best tutorials!!! awsm work......plz prepare such a sereis for AVR Cprogramming...
@cdeba9867
@cdeba9867 4 жыл бұрын
I am devouring your course
@jonsnow9246
@jonsnow9246 7 жыл бұрын
Superb video..I have a doubt In the recursive approach,what happens to the paused function,wont they give an error return statement missing? because for the paused functions there is nothing below return FindMin(root->left); .........and return type of the function is int!
@ktp693
@ktp693 10 жыл бұрын
Very clean and easy to understand! Thanks!
@Gurl975-b9o
@Gurl975-b9o 11 ай бұрын
Can u pl tell its complexity?!
@mersenne2486
@mersenne2486 Жыл бұрын
we don't need to use return in the last line, we can directly call the function, is it that using return reduces stack frame from growing as the last function ends before calling the new function
@ኢትዬ
@ኢትዬ 5 жыл бұрын
You r a great teacher! Keep it up mate!
@Bhargava95
@Bhargava95 4 жыл бұрын
I have decided to give you a Nobel Prize!!
@jaekim9496
@jaekim9496 9 жыл бұрын
Beautifully explained. Thank you so much.
@ryklin1
@ryklin1 8 жыл бұрын
The only thing I do not like about this implementation is that negative integers can be stored in this tree, so returning -1 when the root is NULL creates a conflict. Instead, I think it would be better to throw an exception when the root is null. Does anyone have a better suggestion?
@goodToBeLost
@goodToBeLost 7 жыл бұрын
That's right. But any suggestions on what we could do if we know that the B.S.T can have negative values? :)
@odotodate
@odotodate 6 жыл бұрын
You could return the minimum value of the Integer class. How you get that value depends on your language (i.e. Java = Integer.MIN_VALUE)
@inception252
@inception252 3 жыл бұрын
@@goodToBeLost XDDDD
@5586manali
@5586manali 10 жыл бұрын
when you say root can be used as a local variable, I tried the following code snippet. #include struct node { int data; struct node *next; }; void change_data(struct node *root) { root->data = 7; } int main() { struct node *root; root = (struct node*)malloc(sizeof *root); root->data = 5; change_data(root); printf(" root data:%d",root->data); } With your logic, changing root->data in change_data should not change the root in main function. however the output of this function is 7 not 5. Can you explain the same?
@vzfzabc
@vzfzabc 9 жыл бұрын
Indeed, the answer you get is expected one. Because you are modifying the same chunk of the memory. You pass to the method change_data() an address(which is the reference to the malloced memory) that you keep at **root(pointer to pointer root), and this address is assigned as a value of the **root(pointer to pointer) that you have in change_data which is not equivalent to the **root in main. From the output of the following snippet, you will notice that **root in main() and change_data() is different, however the address they keep is the same. Hope, it helps. #include #include struct node { int data; struct node *next; }; void change_data(struct node *root) { printf("change: * %p ", root); printf("change: **%p ", &root); root->data = 7; } int main() { struct node *root; root = (struct node*)malloc(sizeof *root); root->data = 5; change_data(root); printf("main: * %p ", root); printf("main: **%p ", &root); printf(" root data:%d",root->data); }
@idamooooo
@idamooooo 9 жыл бұрын
+Manali Bhutiyani TL;DR answer: To get the result you are looking for, your function change_data(struct node *root) should return type struct node*. Then in your main, change to: root = root->data=5 That way, your main function is assigned to the address of the newly changed node.
@mohammedamaan7351
@mohammedamaan7351 4 жыл бұрын
int FindMin(BstNode* root) { if (root == NULL) return -1; if (root->left) return FindMin(root->left); else return root->data; }
@akshay8675
@akshay8675 4 жыл бұрын
To find the maximum or minimum element we have to provide the pointer to the root node no? how is it done?
@chintandesai1436
@chintandesai1436 9 жыл бұрын
How do we make sure that current -> left will actually traverse left and not right side ?
@akshay8675
@akshay8675 4 жыл бұрын
To find the maximum or minimum element we have to provide the pointer to the root node no? how is it done?
@tareqdevdiary
@tareqdevdiary 4 жыл бұрын
How to call FindMin() function from main function? Which argument should I pass in FindMin() function?
@danielcarrera6813
@danielcarrera6813 4 жыл бұрын
pass the address of the root node
@MyStar970
@MyStar970 7 ай бұрын
Very well explained
@ujjwal94roy
@ujjwal94roy 5 жыл бұрын
Very nice explanation
@maroben225
@maroben225 9 жыл бұрын
im confused ...if root->left ==NULL ..why wouldnt it go to the first if ( root ==null) ..instead of going to else if (root-left ==null) how will he reconize it ..isnt it a local variable !
@harmanpreetkaur5910
@harmanpreetkaur5910 10 жыл бұрын
seriously awesome videos ..could u plz upload a video on graphs..
@mycodeschool
@mycodeschool 10 жыл бұрын
Harmanpreet Kaur Yeah, I am a bit slow.. I am not getting the time. But Graph is next on my list. Expect some videos on Graph in August.
@srividhyaparthasarathy5401
@srividhyaparthasarathy5401 4 жыл бұрын
Why isn't the condition for while loop is not current!=null and y is it current->next!= Null?
@usama57926
@usama57926 6 жыл бұрын
bro u return -1 if the tree is empty but think if the tree is not empty and the minimum value in tree is also -1 then it will return -1 so how can u manage this condition in main function.
@singhsarbjit
@singhsarbjit 5 жыл бұрын
There is an assumption in this example that he described - "Tree is storing only positive numbers"
@ivannav
@ivannav 6 жыл бұрын
Thanks, great vid!
@Surbhi1811
@Surbhi1811 5 жыл бұрын
I am in love with your videos...awesome
@SumitKumar-fn3gj
@SumitKumar-fn3gj 5 жыл бұрын
And I am in love with you
@usama57926
@usama57926 6 жыл бұрын
amazing explanation
@tonyy08
@tonyy08 6 жыл бұрын
So the minimum for this problem will be 2?
@dattabezawada973
@dattabezawada973 4 жыл бұрын
Can I get a complete C# code for this
@suneelabbigari
@suneelabbigari 4 жыл бұрын
Can someone provide all the possible operations (insert, delete, search, height, print infix , prefix and post fix order) with recursion in single program. Please use "root" as global variable...don't want to return pointer every time. struct node * root = NULL in global scope is must.
@victorstan4813
@victorstan4813 6 жыл бұрын
thank you very much, it helps me a lot!!
@erehuchiha303
@erehuchiha303 4 жыл бұрын
Will it work for a right screwd tree where min element is root itself?
@akhilgupta3664
@akhilgupta3664 4 жыл бұрын
Yes it will definitely worked for all type of binary tree. As Left and Right skewed tree are also Binary tree as they have atmost 2 child actually one child except the leaf node which do not have a child node . So in case of skewed tree to find min in right skewed the first condition will itself true so we return root data as it is. Same in case of finding max in left skewed tree . Hope it helps !!
@malathalaqrabawi7839
@malathalaqrabawi7839 8 жыл бұрын
how to find the next min???
@khaledsaleh4238
@khaledsaleh4238 6 жыл бұрын
I'd think to add another pointer ( let's call it Prev ) and go recursively through the whole left subtree till you find the leaf as he did in this video and just return Prev -> data instead; Hope this helps!
@aliiqbal380
@aliiqbal380 9 жыл бұрын
great work sir. :-)
@ShivamKendre-fc3su
@ShivamKendre-fc3su 3 жыл бұрын
Great video
@jatinverma4788
@jatinverma4788 6 жыл бұрын
why the root in main doesn't change when we are passing the address of root in Findmin()???
@jayantprakash6425
@jayantprakash6425 6 жыл бұрын
bcz we are passing root pointer by reference so function will have its own copy of root pointer, not affecting the original
@rahul2749
@rahul2749 3 жыл бұрын
3:14,4:11,5:34
@kamlendratripathi8963
@kamlendratripathi8963 3 жыл бұрын
what is the time complexity of iterative and recursion approach
@SHIVANSHTHAKUR-cd6lv
@SHIVANSHTHAKUR-cd6lv 3 жыл бұрын
i think O(log(n)) for iterative, because we are dividing are problem by half at each step and may be same in recursion. Instead of big-O we can use theta as well because we are sure that it is the left most/right most element for min/max elements.
@sumved123
@sumved123 10 жыл бұрын
You are awesome! :)
@alimahmood4158
@alimahmood4158 5 жыл бұрын
kindly make a video on insert a node in bst
@abhisheksingh5558
@abhisheksingh5558 7 жыл бұрын
this code won't work for all cases
@inception252
@inception252 3 жыл бұрын
i find it quite blank to test it anyone know?
@hussainulhassan2199
@hussainulhassan2199 4 жыл бұрын
thanks chachu
@kal5211
@kal5211 3 жыл бұрын
My man.
@denisr.8248
@denisr.8248 6 жыл бұрын
Good video man TXH a lot :P
@usama57926
@usama57926 6 жыл бұрын
Thank u brother
@premkumarreddy6893
@premkumarreddy6893 Жыл бұрын
thank u🤩
@kj__entertainment
@kj__entertainment 7 жыл бұрын
sdf
Find height of a binary tree
7:09
mycodeschool
Рет қаралды 570 М.
Delete a node from Binary Search Tree
18:27
mycodeschool
Рет қаралды 1,1 МЛН
А я думаю что за звук такой знакомый? 😂😂😂
00:15
Денис Кукояка
Рет қаралды 3,2 МЛН
ТВОИ РОДИТЕЛИ И ЧЕЛОВЕК ПАУК 😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 6 МЛН
БУ, ИСПУГАЛСЯ?? #shorts
00:22
Паша Осадчий
Рет қаралды 2,9 МЛН
Top 7 Algorithms for Coding Interviews Explained SIMPLY
21:22
Codebagel
Рет қаралды 442 М.
Check if a binary tree is binary search tree or not
16:30
mycodeschool
Рет қаралды 380 М.
Find Min and Max Element In Binary Search Tree  - BST
4:28
Data structures: Binary Search Tree
19:28
mycodeschool
Рет қаралды 1,3 МЛН
Binary search tree - Implementation in C/C++
18:36
mycodeschool
Рет қаралды 1,3 МЛН
New divisibility rule! (30,000 of them)
26:51
Stand-up Maths
Рет қаралды 276 М.
How to find Maximum value in a Binary Tree? (Recursive) | Animation
26:20
Find maximum (or minimum) in Binary Tree | GeeksforGeeks
6:29
GeeksforGeeks
Рет қаралды 33 М.
Inorder Successor in a binary search tree
17:58
mycodeschool
Рет қаралды 362 М.
Minimax with Alpha Beta Pruning
13:44
John Levine
Рет қаралды 348 М.