Java Binary Search Tree 2

preview_player
Показать описание

Welcome to my 2nd video on Binary Trees in Java. If you haven't seen part 1, definitely watch it first or this will be confusing binary tree in Java.

In this part of the tutorial, I will take you step-by-step through the process of deleting nodes in a binary tree. This topic seems to be confusing to many people. I personally prefer to build trees with the builder design pattern like I showed here Encapsulate Composite with Builder, but it is also important to understand the basics of the binary tree.
Рекомендации по теме
Комментарии
Автор

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.

smartdroidesign
Автор

You are literally getting me through Uni, thanks so much for making these videos my lecturers don't explain sh&t!

matthoy
Автор

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

derekbanas
Автор

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.

janardhan
Автор

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

jonmultimedia
Автор

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.

derekbanas
Автор

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.

robertnorton
Автор

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.

derekbanas
Автор

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.

caseyscarborough
Автор


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.

seriouslythodonteven
Автор

Possible Correction?: 8:20 parent.rightchild = focusNode.rightchild (not leftchild because leftchild is null, we check for it in the if statement)

TheJP
Автор

Hi, Check out my Java tutorial and more specifically the Swing part that deals with GUI. They are all on my YouTube channel and here on my website newthinktank.

derekbanas
Автор

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

derekbanas
Автор

I understand binary tree code implementation in java with full concept of it "Loud and Clear"; Thank you

mesfinhaftu
Автор

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

derekbanas
Автор

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

derekbanas
Автор

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!

brandogg
Автор

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.

SoftwareSimplified-Dtons
Автор

Γεια σας Αγαπητέ προπονητής,

Απλά θέλω να πω μια τίμια ευχαριστώ σε εσάς.

Κυριακή μου θα έχει μια καλή αρχή.

Σας εύχομαι όλα τα καλά πράγματα στη ζωή.

Ελπίζοντας για το webservice ΠΕΡΙΦΕΡΕΙΑ SOAP κάποια μέρα.

Με τον τρόπο που η ειδική φοιτητής κέρδισε αργυρό μετάλλιο :)

φροντίζω

japanuser
Автор

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

derekbanas