Man, this was a journey. From Linked List through Double Linked and Binary Tree you did a fantastic job. I was able to implement all of this into an actual project with very little efforts and great satisfaction. Please keep this up, Java is far from dead into 2018 and it's a beautiful language, I am glad to see resources like this on youtube.
You're very welcome :) Yes the Sedgewick book is pretty good. Stay away from Cormen's Introduction to Algorithms. I can't believe anyone would ever use it for teaching unless they just like to confuse their students. 1. Yes 50 is the root because it was the first node entered. 2. The easiest way to solve this is to delete a node and then add a new one I hope that helps
at 8:15 minutes, under if(focusNode.leftChild == null) in else condition (last check), parent.rightChild = focusNode.leftChild. focusNode.leftChild is already NULL, setting to null would remove link to right sub tree. it should be parent.rightChild = focusNode.rightChild.
Your very welcome. The list you are referring to is made from two linked lists with the same data, but ordered in the opposite direction. I decided to cover graphs and advanced trees in their own tutorial. I'll get to that very soon.
I know it's an old video...but..You have no idea how much you've helped me with my data structures course work. Hard subject and so many doubts. Had to addapt the whole thing for strings instead of intergers, but I'm almost finished, thanks to you :) Keep up the great work :D
Derek, your videos are absolutely superb! They help so much with understanding the fundamentals of different java tools and techniques. These videos and sample code have aided me greatly, thank you.
At around 8:20 in the video on line 235 the end should be .rightChild, not .leftChild. Just for anyone following along with the video. It is correct in the downloadable code provided.
I thought the same thing right away. I assume this is the correct behavior; otherwise we end up pointing at a null and losing any possible sub-trees on the right child. What do you think Derek?
Γεια σας Αγαπητέ προπονητής, Απλά θέλω να πω μια τίμια ευχαριστώ σε εσάς. Κυριακή μου θα έχει μια καλή αρχή. Σας εύχομαι όλα τα καλά πράγματα στη ζωή. Ελπίζοντας για το webservice ΠΕΡΙΦΕΡΕΙΑ SOAP κάποια μέρα. Με τον τρόπο που η ειδική φοιτητής κέρδισε αργυρό μετάλλιο :) φροντίζω
Binary trees aren't supposed to have duplicates. If you need duplicates it is better to use heaps normally. I cover them at the end of the tutorial series
You're very welcome :) Please give me a bit more information on what part of the video you're thinking about. I made this so long ago that I want to make sure I get the answer right
Sir if (replacement != replacedNode.rightChild) { replacementParent.leftChild = replacement.rightChild; replacement.rightChild = replacedNode.rightChild; } this part not at all able to grasp, can you please help me in getting these lines, i mean in what case we come into this if statement. Thank you.
Hello Derek. I am an IT student and i would like to thank you for your tutorials. Really helpful!. I have a question. What if the node with the value 30 has only a left child and we would like to delete 30. What will happen then? Thank you!
Thanks so much for your videos. Been working on BSTs in Data Structures and they're relatively easy to follow and explain, but kind of difficult to implement in the beginning, so I really appreciate this! Perfect timing too!
***** it doesn't matter how many children, you want to find the smallest value in the right subtree and replace the deleted node with the smallest value. this is correct because everything in the right subtree is bigger than the left, so the binary tree property is not broken. The replacement method accounts for this issue and I believe you can find out why by looking at the replacement method carefully.
Unfortunately he doesn't mention this anywhere in the video. All of his slides show the replacement node being the right child of the node being removed. This is not really correct, as you said, you want to replace the node with the lowest value in the right subtree (the largest value in the left subtree would also work). I think there is where the confusion has come from. Adding a left child to 75, and explaining how you would delete 50 would have made this clear IMO.
Thank you once again Derek! i´ve got a few questions: 1)Does a Circular list is a form of Simply linked list or is it a form of double linked list? 2) Do you have any tutorial on Graphs?
Hey Derek. When you are looking to remove the node if the focusNode.leftChild == null... if isItALeftChild is false you set parent.rightChild = focusNode.leftChild but shouldn't it be parent.rightChild = focusNode.rightChild?
Idris Kasumu I agree, I noticed the mistake as well, it is on line 235, in the video it reads parent.rightChild = focusNode.leftChild; it should read parent.rightChild = focusNode.rightChild; refer to line 225, it states focusNode.leftChild to be null the code in the video incorrectly cuts off a part of the tree otherwise a great video
Hello Derek! As always great video! :) However, I have a question... 8:19 (line 235): shouldn't there be: parent.rightChild = focusNode.rightChild; instead of yours: parent.rightChild = focusNode.leftChild; Because focusNode.leftChild is null in that case.
Thank you for a quick response. In BinaryTree.java, as soon as I delete '50', '25 becomes the root node (or at least that is my understanding) theTree.preorderTraverseTree(theTree.root); //inorder does same Anything I add now, goes into, possibly, an appropriate spot, not root. Would be nice to print the tree in a "tree structure" like you show in later video to see it visually & get a confirmation. Pls give it a shot & let me know if your results/understanding it different than mine.
Hi, Derek, please update the case when you delete the root and 75 has a left child. It seems like the leftChild of 50 should slide all the way down to the leftmost child of right child of root, right?
Sorry I was mobile the last time and didn't quite understand your question. Why not just find the node and the dat you want to change and then change it directly? Is there a reason why you want to create a new Node object? Sorry if I'm missing something. I'm a bit scattered to day with work. I'm going to revisit algorithms again in the future and cover the topics that are confusing people. Sorry about the confusion
I've often needed to program trees for affiliate programs, and found deletions more complicated, because if you are talking about human referrals, it is not fair that a right child of a deleted node has potential to be elevated and thus receive the deleted node's referrals, while the left side does not. I'm not sure if I might be missing something though because I"m currently studying this in my Data Structures class. Another question I had was say 75 ONLY has a left child. If 75 is deleted, we would simply replace it with the left child, correct? Sorry for so many questions I'm very interested in this sort of subject hahah Oh and major thanks Derek Banas!!!!..throughout my studies your videos have been like a safety net - if I don't understand something confusing you have a brilliant way of explaining even the most complicated subjects so they sound obvious. Thank you so much. I think a lot of students at my school watch and we recommend you often in our forums.
Thank you for the video it was very clear and it made the concept of BST much understandable for me, keep up the good work (:. Love your voice btw, it's very calm.
Thanks for your Video, really helps alot. Here's one question, does the solution work if the node-to-deleted has both right and left child. And those children have both right and left child as well. In other words, the deleting node have 2 children and 4 grandchildren. Thanks ;)
Just a doubt in the condition else if (focusNode.getLeft()==null) should not the last else condition should be parent.right=focusNode.right; since focusNode.left isalready null ?
Awesome, dude. Just one suggestion if you don't mind. It would be better if you go slightly slower while writing the code, cause sometimes I find myself having to pause and rewind the thing to get the hang of whats going on. Just a suggestion. You are doing a great job.
Hi Derek, Thank you very much for awesome video, there is a problem while adding a node to tree with a key which is already exists in tree, instead of updating the node value , its creating a new node, following will resolve the issue //in addNode method if (key < focusNode.key) { focusNode = focusNode.left; if (focusNode == null) { parent.left = newNode; return; } } else if(key > focusNode.key){ focusNode = focusNode.right; if (focusNode == null) { parent.right = newNode; return; } }else{ parent.value=value; return; }
Mistake with the inOrderTraverseTree method. It uses preOverTraverseTree in some of its calls. Very important to fix this error! It is recursively calling the wrong methods!
Thanks Derek. Just a quick question. If the node you want to delete has a right child that has a left child, does this left child replace the deleted node or does the delete node's right child take its place?
hey Derek, Thanks for such awesome videos. They are really good. The only thing is, you seems to be bit fast in your speed of explaining things. If you can slow down a bit while explaining/talking, then the awesomeness of your videos will be just doubled .. :)
Derek Banas I like the speed personally. Even if I need to rewind and pause or whatever, beauty of the video! That being said, keep up the excellent work! Favorite programming tutorials anywhere I have found.
Thank you! Derek for making & posting these videos, I am going to start by reading Sedgewick, Algorithms & decided to go through your series first since I am a better visual learner. Few questions on Binary tree Q1. Why did 50 become the Root node (no parent). Just because we inserted it first? Should there be considerations while determining how to add nodes? Q2. Is there a replace node method? What if I wanted to add a new node "40 - Big Boss" & remove "50 - Boss" for e.g. New CEO as root?
great videos, this one got me a bit confused though due t what you said when you looked at the right side and then during the code, towards the end I just got lost, so I am rewatching now.
I have a question: At 9:38, What does it mean for: (L252)Replacement.leftChild = focusNode.leftChild; What is this for, could someone explain?Thanks! Why is it leftChild?
Hi Derek, your code is using Binary Tree as a title. Sort of. But it is truely binary search tree, a more advanced binary tree, isn't it? And thank you again for the extremly well organized/edited, beefy tutorial.
Thanks for the awesome tutorials Derek! Is it a way to implement a scanner function into the code so the user can choose what node he/she wants to replace? If of course the user has all the values of the tree, or the message in the scanner window says something like "Choose what value you want to remove between 25 and 100"
Derek Banas It would be crazy to ask this question, but If you can deliver these lectures in a month, then it would help in my interview. Believe it or not, You are helping a lot to the society. More power to you!!!
Hi Derek, Can you also make a tutorial on how to find the common ancestor between two binary tree? This question was asked to me in my interview and I wasn't able to solve. Appreciate if you could do one video on this.
I am new to java and I was wondering is there a predefined Tree class in java so you can do like Tree mytree = new Tree( ) and with all add delete etc functions?
Hey, Derek, thanks for the great vids! One comment: I think your code would be more compact if you slightly modified the findNode method to keep track of isItALeftChild and reuse that method within the remove method
Man, this can help me very much tackle my 1 to many and many to many comparison problem I have with my chess video game. How would you suggest I can handle this situation with BinaryTrees. I just cannot visualized a chess plight like a binary tree, because you have to start with the playing chess piece and figure out all its safe and unsafe moves, and then come up with all the opponent's, again, safe and unsafe moves against the one chess piece safe and unsafe moves, and determine the best possible move against the rest of the current player's chess pieces...If I am ever able to place this into a binary tree, it would be a very complicated one, which would take at least tree values each would be consider a key by itself.. What I like about your video is how you exemplify on a simple binary tree. Could you do a more complex binary tree, and maybe that can help me deal with my 1 to many and many to many problem, I have with my chess game.
I can't really help you much but i've seen some AI algorithms to solve this kind of problem. Minimax algorithm probably is worth checking. Sorry if i couln't help.
Ένα ακόμα video αλγόριθμος και στη συνέχεια θα ξεκινήσει το Android. Θα πρέπει να καλύπτει πολλά από τα θέματα που έχουν ζητήσει. Χαίρομαι που εσείς απολαμβάνετε τα βίντεο
Derek Banas I've actually found a flaw, I'm not sure where in the code it is though. If I enter numbers that are in order, (1 2 3 4 5 6 7 8 9 10 or 2 4 6 8 10 12 14 16 18 20) it deletes from the selected node and on. So if I delete 4, everything after the 4 is gone too. I've tried searching for the other nodes, running the Max function for the max value in the heap but will just show the next smallest number, same goes for an inorder traversal of it. Any ideas?
There is more simple way to deal with node that has two subtrees. Just copy the minimum value of the right subtree, place it in the position of original node, and deal with the duplicate node. If the node has right tree, link his parent to his right child.If not, delete it.
Hi sir Derek! good day. your videos are a great help for me as an information technology student so keep it up but im just having a little problem. i want to make the values of the nodes to be inputted by a user and using a gui. but im having a hard time implementing it.. for example once a user inputted 25 it is considered to be the root node then the user inputted another value ex.20. so 20 should be placed at the left child node of 25.. but how can i do it graphically?? please help -_-
Do you know where I can find how to save a binary search tree of in, pre or post order to a file and also able to recreate the tree from that file?. Through any method such as serialization or any other? Thanks in advance, great tutorial :)
Take a look at the next video in this series. I show how to print out tree structures. That will help you visualize the tree on the screen and that will aid in learning.
What happens with deletion, is that the node that gets deleted is replaced with the minimum value of the right subtree, so if 75 had a left child, meaning it's less than 75, that child will replace 50
Man, this was a journey.
From Linked List through Double Linked and Binary Tree you did a fantastic job.
I was able to implement all of this into an actual project with very little efforts and great satisfaction.
Please keep this up, Java is far from dead into 2018 and it's a beautiful language, I am glad to see resources like this on youtube.
Thank you :) I'm happy you enjoyed it. I'll be doing much more with algorithms soon
Please do! I am now trying to refactor your code to a more concrete example, not so easy ehehe
You're very welcome :) Yes the Sedgewick book is pretty good. Stay away from Cormen's Introduction to Algorithms. I can't believe anyone would ever use it for teaching unless they just like to confuse their students.
1. Yes 50 is the root because it was the first node entered.
2. The easiest way to solve this is to delete a node and then add a new one
I hope that helps
at 8:15 minutes, under if(focusNode.leftChild == null) in else condition (last check), parent.rightChild = focusNode.leftChild.
focusNode.leftChild is already NULL, setting to null would remove link to right sub tree. it should be parent.rightChild = focusNode.rightChild.
I also had the same doubt.
Thank you! this helped me allot. Something was wrong and couldn't figure out what it was!
that's right just discover after detail analyzing it xd
Glad you were able to see that too. It was a mistake on the video.
You are literally getting me through Uni, thanks so much for making these videos my lecturers don't explain sh&t!
+Matthew Hoy I'm very happy that I could help :)
Your very welcome. The list you are referring to is made from two linked lists with the same data, but ordered in the opposite direction. I decided to cover graphs and advanced trees in their own tutorial. I'll get to that very soon.
I know it's an old video...but..You have no idea how much you've helped me with my data structures course work. Hard subject and so many doubts.
Had to addapt the whole thing for strings instead of intergers, but I'm almost finished, thanks to you :)
Keep up the great work :D
Thank you very much :) I'm very happy to hear that I helped
Derek, your videos are absolutely superb! They help so much with understanding the fundamentals of different java tools and techniques. These videos and sample code have aided me greatly, thank you.
At around 8:20 in the video on line 235 the end should be .rightChild, not .leftChild. Just for anyone following along with the video. It is correct in the downloadable code provided.
I have been planning on doing that for over a year. I was going to make it from scratch. I'll get to that ASAP
Possible Correction?: 8:20 parent.rightchild = focusNode.rightchild (not leftchild because leftchild is null, we check for it in the if statement)
I thought the same thing right away. I assume this is the correct behavior; otherwise we end up pointing at a null and losing any possible sub-trees on the right child. What do you think Derek?
mars009 I agree. I tested this out and found that I lost the right child because it was replaced by a null left child.
Yep! In his source code in the link he has it corrected though :)
Γεια σας Αγαπητέ προπονητής,
Απλά θέλω να πω μια τίμια ευχαριστώ σε εσάς.
Κυριακή μου θα έχει μια καλή αρχή.
Σας εύχομαι όλα τα καλά πράγματα στη ζωή.
Ελπίζοντας για το webservice ΠΕΡΙΦΕΡΕΙΑ SOAP κάποια μέρα.
Με τον τρόπο που η ειδική φοιτητής κέρδισε αργυρό μετάλλιο :)
φροντίζω
I understand binary tree code implementation in java with full concept of it "Loud and Clear"; Thank you
Binary trees aren't supposed to have duplicates. If you need duplicates it is better to use heaps normally. I cover them at the end of the tutorial series
I'm doing my best to find the perfect speed for these tutorials. Thank you for the input :)
You're very welcome :) Please give me a bit more information on what part of the video you're thinking about. I made this so long ago that I want to make sure I get the answer right
Sir if (replacement != replacedNode.rightChild) {
replacementParent.leftChild = replacement.rightChild;
replacement.rightChild = replacedNode.rightChild;
}
this part not at all able to grasp, can you please help me in getting these lines,
i mean in what case we come into this if statement.
Thank you.
Hello Derek. I am an IT student and i would like to thank you for your tutorials. Really helpful!. I have a question. What if the node with the value 30 has only a left child and we would like to delete 30. What will happen then? Thank you!
I corrected the code on the site. Sorry about that. I write most of this stuff out of my head and I slip up on occasion
Thanks so much for your videos. Been working on BSTs in Data Structures and they're relatively easy to follow and explain, but kind of difficult to implement in the beginning, so I really appreciate this! Perfect timing too!
I'm very happy that I was able to explain it in a way that helped :)
*****
it doesn't matter how many children, you want to find the smallest value in the right subtree and replace the deleted node with the smallest value. this is correct because everything in the right subtree is bigger than the left, so the binary tree property is not broken. The replacement method accounts for this issue and I believe you can find out why by looking at the replacement method carefully.
Unfortunately he doesn't mention this anywhere in the video. All of his slides show the replacement node being the right child of the node being removed. This is not really correct, as you said, you want to replace the node with the lowest value in the right subtree (the largest value in the left subtree would also work). I think there is where the confusion has come from.
Adding a left child to 75, and explaining how you would delete 50 would have made this clear IMO.
Thank you very much :) I'm happy that you liked it
Yes the heap tutorial will be the last for this series. I'll make an advanced algorithm tutorial after I cover Android for a bit
Thank you once again Derek!
i´ve got a few questions:
1)Does a Circular list is a form of Simply linked list or is it a form of double linked list?
2) Do you have any tutorial on Graphs?
Hey Derek. When you are looking to remove the node if the focusNode.leftChild == null... if isItALeftChild is false you set parent.rightChild = focusNode.leftChild but shouldn't it be parent.rightChild = focusNode.rightChild?
YEAH I WATCHED THIS VIDEO TONS OF TIMES...HIS ALGORITHM FOR THE LEFT CHILD BEING NULL IS WRONG...PLEASE CORRECT other than that it was great
Idris Kasumu I agree, I noticed the mistake as well, it is on line 235,
in the video it reads
parent.rightChild = focusNode.leftChild;
it should read
parent.rightChild = focusNode.rightChild;
refer to line 225, it states focusNode.leftChild to be null
the code in the video incorrectly cuts off a part of the tree
otherwise a great video
Hello Derek! As always great video! :)
However, I have a question...
8:19 (line 235):
shouldn't there be: parent.rightChild = focusNode.rightChild;
instead of yours: parent.rightChild = focusNode.leftChild;
Because focusNode.leftChild is null in that case.
This is just the way I was taught
Thank you for a quick response. In BinaryTree.java, as soon as I delete '50', '25 becomes the root node (or at least that is my understanding)
theTree.preorderTraverseTree(theTree.root); //inorder does same
Anything I add now, goes into, possibly, an appropriate spot, not root. Would be nice to print the tree in a "tree structure" like you show in later video to see it visually & get a confirmation. Pls give it a shot & let me know if your results/understanding it different than mine.
Thank you :) Im always here and I'm happy to answer any questions you have
Hi, Derek, please update the case when you delete the root and 75 has a left child. It seems like the leftChild of 50 should slide all the way down to the leftmost child of right child of root, right?
Sorry I was mobile the last time and didn't quite understand your question. Why not just find the node and the dat you want to change and then change it directly? Is there a reason why you want to create a new Node object? Sorry if I'm missing something. I'm a bit scattered to day with work. I'm going to revisit algorithms again in the future and cover the topics that are confusing people. Sorry about the confusion
I've often needed to program trees for affiliate programs, and found deletions more complicated, because if you are talking about human referrals, it is not fair that a right child of a deleted node has potential to be elevated and thus receive the deleted node's referrals, while the left side does not. I'm not sure if I might be missing something though because I"m currently studying this in my Data Structures class. Another question I had was say 75 ONLY has a left child. If 75 is deleted, we would simply replace it with the left child, correct? Sorry for so many questions I'm very interested in this sort of subject hahah
Oh and major thanks Derek Banas!!!!..throughout my studies your videos have been like a safety net - if I don't understand something confusing you have a brilliant way of explaining even the most complicated subjects so they sound obvious. Thank you so much. I think a lot of students at my school watch and we recommend you often in our forums.
Quick question. What if multiple Nodes have the same key? How do we bypass that?
Thank you for the video it was very clear and it made the concept of BST much understandable for me, keep up the good work (:. Love your voice btw, it's very calm.
Thanks for your Video, really helps alot.
Here's one question, does the solution work if the node-to-deleted has both right and left child. And those children have both right and left child as well. In other words, the deleting node have 2 children and 4 grandchildren.
Thanks ;)
Just a doubt in the condition else if (focusNode.getLeft()==null) should not the last else condition should be parent.right=focusNode.right; since focusNode.left isalready null ?
Awesome, dude. Just one suggestion if you don't mind. It would be better if you go slightly slower while writing the code, cause sometimes I find myself having to pause and rewind the thing to get the hang of whats going on. Just a suggestion. You are doing a great job.
Hi Derek,
Thank you very much for awesome video,
there is a problem while adding a node to tree with a key which is already exists in tree, instead of updating the node value , its creating a new node, following will resolve the issue
//in addNode method
if (key < focusNode.key) {
focusNode = focusNode.left;
if (focusNode == null) {
parent.left = newNode;
return;
}
} else if(key > focusNode.key){
focusNode = focusNode.right;
if (focusNode == null) {
parent.right = newNode;
return;
}
}else{
parent.value=value;
return;
}
Derek you just got yourself a new subscriber this will get me through cs. You're a lifesaver!! keep up the videos :)
Thank you :) I'm very happy to be of help
Hey Derek, I am wondering if you plan on doing a video on AVL trees, or balanced binary search trees?
+Philthy Phil Yes that is coming soon
Yes please would love to see a video on it thanks :D
I'm waiting here too
Could I somehow adapt this to delete a node from a tree with more than one child? How would the logic of that look like?
Mistake with the inOrderTraverseTree method. It uses preOverTraverseTree in some of its calls. Very important to fix this error! It is recursively calling the wrong methods!
You left the light on for me!
Thank you for the compliment :)
You explained it in the best way possible. :)
Thanks Derek Banas
Piyush Ramnani Thank you for the compliment :) I'm glad I could help.
Thanks Derek. Just a quick question. If the node you want to delete has a right child that has a left child, does this left child replace the deleted node or does the delete node's right child take its place?
hey Derek,
Thanks for such awesome videos. They are really good.
The only thing is, you seems to be bit fast in your speed of explaining things. If you can slow down a bit while explaining/talking, then the awesomeness of your videos will be just doubled .. :)
Sumit Rathore You're very welcome :) Sorry about the speed I'm working on it
Derek Banas I like the speed personally. Even if I need to rewind and pause or whatever, beauty of the video! That being said, keep up the excellent work! Favorite programming tutorials anywhere I have found.
How to write logic for building binary tree which has parent key equal to some of children keys? All the nodes will be placed as with the same logic.
Thank you! Derek for making & posting these videos, I am going to start by reading Sedgewick, Algorithms & decided to go through your series first since I am a better visual learner.
Few questions on Binary tree
Q1. Why did 50 become the Root node (no parent). Just because we inserted it first? Should there be considerations while determining how to add nodes?
Q2. Is there a replace node method? What if I wanted to add a new node "40 - Big Boss" & remove "50 - Boss" for e.g. New CEO as root?
No problem at all, just thought it might help a few people. Thanks a lot for the videos by the way, this whole series is killer!
Love your videos Derek.
One error:
Line 235 should be:
parent.rightChild = focusNode.rightChild;
Thank you :) Sorry about the error
Thank you very much :) And, thanks for helping others. That is much appreciated
great videos, this one got me a bit confused though due t what you said when you looked at the right side and then during the code, towards the end I just got lost, so I am rewatching now.
Hi Derek, why you replace the deleted node with the right child. why not the rightmost node in the left subtree?
I have a question: At 9:38, What does it mean for:
(L252)Replacement.leftChild = focusNode.leftChild;
What is this for, could someone explain?Thanks! Why is it leftChild?
Hi Derek, your code is using Binary Tree as a title. Sort of. But it is truely binary search tree, a more advanced binary tree, isn't it? And thank you again for the extremly well organized/edited, beefy tutorial.
Jiemin Xi Your welcome :) Yes you are correct that this is a binary search tree
Thanks for the awesome tutorials Derek! Is it a way to implement a scanner function into the code so the user can choose what node he/she wants to replace? If of course the user has all the values of the tree, or the message in the scanner window says something like "Choose what value you want to remove between 25 and 100"
Derek,
I wish, I would see your lectures on Red black trees and graphs
Ethashamuddin Mohammed I'm hoping to cover those very soon.
Derek Banas It would be crazy to ask this question, but If you can deliver these lectures in a month, then it would help in my interview. Believe it or not, You are helping a lot to the society. More power to you!!!
Hi Derek, Can you also make a tutorial on how to find the common ancestor between two binary tree? This question was asked to me in my interview and I wasn't able to solve. Appreciate if you could do one video on this.
i dont know why i can't see anyone better than you derek ^_^ thank u again my teacher
mohammad omer Thank you for the nice message :) I'm very happy I could help
Awesome tutorial as always :) These really help aiding me with my data structures class.
Cheaper Thank you :) I'm happy that I could help
How could the insert method be modified to work with a boolean return value?
Great video by the way you explained it much better than my professor!!
I am new to java and I was wondering is there a predefined Tree class in java so you can do like Tree mytree = new Tree( ) and with all add delete etc functions?
Pento Tom This should help docs.oracle.com/javase/7/docs/api/java/util/TreeSet.html
How to create Java program for
Are two Binary Trees mirror image of each other?
Coding in Java Eclipse Please help me
Thanks for this video man, so helpful🤗🤗🤗
You didn't explain the basis of deleting and how we choose the replacement for the node ..
Thank you so much Derek! Your videos are just awesome, you can't imagine HOW MUCH they help me (and many many others)! :)
FreuleinN Thank you for the kind note :) I greatly appreciate it.
Great style of teaching . Thank you :)
Thank you :)
You sound like Andy from the office, great video thanks!
Do you still plan on creating a video for Red-Black Binary Search Trees?
Jess Farmer I hope to cover advanced algorithms at some point. I want to properly cover Android first though.
Derek Banas Well that's great, thanks for taking the time to create these videos. You're the man!
Hey, Derek, thanks for the great vids! One comment: I think your code would be more compact if you slightly modified the findNode method to keep track of isItALeftChild and reuse that method within the remove method
Thank you for the input :)
i need to find how to check if some node is lower then the subtree nodes and to add the sum of them anyone help!!
What about generic ?
very helpful video but algo cant remove the actual root :/
not sure why...
Man, this can help me very much tackle my 1 to many and many to many comparison problem I have with my chess video game. How would you suggest I can handle this situation with BinaryTrees. I just cannot visualized a chess plight like a binary tree, because you have to start with the playing chess piece and figure out all its safe and unsafe moves, and then come up with all the opponent's, again, safe and unsafe moves against the one chess piece safe and unsafe moves, and determine the best possible move against the rest of the current player's chess pieces...If I am ever able to place this into a binary tree, it would be a very complicated one, which would take at least tree values each would be consider a key by itself..
What I like about your video is how you exemplify on a simple binary tree. Could you do a more complex binary tree, and maybe that can help me deal with my 1 to many and many to many problem, I have with my chess game.
I can't really help you much but i've seen some AI algorithms to solve this kind of problem.
Minimax algorithm probably is worth checking.
Sorry if i couln't help.
Ένα ακόμα video αλγόριθμος και στη συνέχεια θα ξεκινήσει το Android. Θα πρέπει να καλύπτει πολλά από τα θέματα που έχουν ζητήσει. Χαίρομαι που εσείς απολαμβάνετε τα βίντεο
Is this comment in greek or does youtube autotranslated it just to mess with me?
Thank you :) You're very kind
i noticed in the beginning you didnt address the issue of when deleting a node that has 2 children which are both subtrees
Thank you so much for this! Was having a hard time with the deletion!
You're very welcome :)
Derek Banas I've actually found a flaw, I'm not sure where in the code it is though. If I enter numbers that are in order, (1 2 3 4 5 6 7 8 9 10 or 2 4 6 8 10 12 14 16 18 20) it deletes from the selected node and on. So if I delete 4, everything after the 4 is gone too. I've tried searching for the other nodes, running the Max function for the max value in the heap but will just show the next smallest number, same goes for an inorder traversal of it. Any ideas?
Random ordered numbers do work though!
Dan Gray I also use your same algorithm to insert and traverse the tree, I went back to make sure I had those right too
Dan Gray I read the further comments and went to your site and got the code there. Works perfectly! Again, thanks again!
Very clear!!! thank you derek
You're very welcome :)
There is more simple way to deal with node that has two subtrees. Just copy the minimum value of the right subtree, place it in the position of original node, and deal with the duplicate node. If the node has right tree, link his parent to his right child.If not, delete it.
BTW,I really enjoy your tutorials. I love your code style and explicit thoughts.
Xiaodong Yang Thank you :)
Hi sir Derek! good day. your videos are a great help for me as an information technology student so keep it up but im just having a little problem. i want to make the values of the nodes to be inputted by a user and using a gui. but im having a hard time implementing it.. for example once a user inputted 25 it is considered to be the root node then the user inputted another value ex.20. so 20 should be placed at the left child node of 25.. but how can i do it graphically?? please help -_-
Thank you ver much for this.
Helps me understand those things once again, since I'm a little bit out of practice :)
+Bl4cKR0xX You're very welcome :)
Hi Derek! Thanks for the great video tutorial...I just wanted to ask if this is binary search tree..not just binary tree?
michael ngangom You're very welcome :) Yes this is a binary search tree.
Do you know where I can find how to save a binary search tree of in, pre or post order to a file and also able to recreate the tree from that file?. Through any method such as serialization or any other? Thanks in advance, great tutorial :)
ZBCuber Have you seen this stackoverflow.com/questions/2694005/write-to-file-binary-search-tree
ahh, that is useful, thankyou
Derek,
Have you done any videos that cover counting leaves or counting nodes using recursion?
Dave Thatcher I have not done that specifically, but I have a recursion tutorial
Hi Derek,
I am a little confused. What if the right child of the node to be deleted has two children?
We are deleting root node, 50. Now What if 75 has a left node?
You would find leftmost child of 75.
You have done a mistake at time 8.19 that is you have to write parent.rightchild=focusNode.rightchild; line number 235
Can you change it? Thx
Change what?
what do you mean by setting the root node to null on 5:56?
how can the root node be null?
the tree consists of only root node and it also happens to the node which has to be deleted. So we nullified the root itself
Muchas gracias :)
Take a look at the next video in this series. I show how to print out tree structures. That will help you visualize the tree on the screen and that will aid in learning.
do you have any avl implementation?
Your tutorials on binary Search tree are very good. Do you know a good one about red black trees ? In order to balance trees.
Thank you :) No I don't but I plan on making one as soon as I get a chance.
IF 75 had a left child what will happen when deleting 50
What happens with deletion, is that the node that gets deleted is replaced with the minimum value of the right subtree, so if 75 had a left child, meaning it's less than 75, that child will replace 50
@@arshad887 this really helped
Could you make a tutorial on how to make a custom PC?
2:00 whatever child you move what if it has its own left and right already
do you plan to cover treaps?
this guy is so great ! Thank you for this .....
Please explain the code inside the getReplacementNode method.
Agnibha Chakraborty yes