Java Binary Search Tree 2

Поділитися
Вставка
  • Опубліковано 19 вер 2024

КОМЕНТАРІ • 226

  • @smartdroidesign7998
    @smartdroidesign7998 6 років тому +3

    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.

    • @derekbanas
      @derekbanas  6 років тому +1

      Thank you :) I'm happy you enjoyed it. I'll be doing much more with algorithms soon

    • @smartdroidesign7998
      @smartdroidesign7998 6 років тому

      Please do! I am now trying to refactor your code to a more concrete example, not so easy ehehe

  • @derekbanas
    @derekbanas  11 років тому +4

    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

  • @janardhan516
    @janardhan516 8 років тому +61

    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.

    • @thevijayraj34
      @thevijayraj34 7 років тому +1

      I also had the same doubt.

    • @nvurbanninja69
      @nvurbanninja69 7 років тому

      Thank you! this helped me allot. Something was wrong and couldn't figure out what it was!

    • @HC-qe8ii
      @HC-qe8ii 3 роки тому

      that's right just discover after detail analyzing it xd

    • @rubenhernandezgarcia303
      @rubenhernandezgarcia303 2 роки тому

      Glad you were able to see that too. It was a mistake on the video.

  • @matthoy9089
    @matthoy9089 8 років тому +16

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

    • @derekbanas
      @derekbanas  8 років тому +3

      +Matthew Hoy I'm very happy that I could help :)

  • @derekbanas
    @derekbanas  11 років тому

    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.

  • @jonmultimedia
    @jonmultimedia 4 роки тому +1

    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

    • @derekbanas
      @derekbanas  4 роки тому +2

      Thank you very much :) I'm very happy to hear that I helped

  • @robertnorton701
    @robertnorton701 8 років тому +2

    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.

  • @caseyscarborough
    @caseyscarborough 11 років тому

    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.

  • @derekbanas
    @derekbanas  11 років тому +1

    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

  • @TheJP12323
    @TheJP12323 10 років тому +9

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

    • @mars009
      @mars009 10 років тому

      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?

    • @wizzdude2006
      @wizzdude2006 10 років тому

      mars009 I agree. I tested this out and found that I lost the right child because it was replaced by a null left child.

    • @gkeenleyside
      @gkeenleyside 9 років тому +1

      Yep! In his source code in the link he has it corrected though :)

  • @123japanuser
    @123japanuser 11 років тому

    Γεια σας Αγαπητέ προπονητής,
    Απλά θέλω να πω μια τίμια ευχαριστώ σε εσάς.
    Κυριακή μου θα έχει μια καλή αρχή.
    Σας εύχομαι όλα τα καλά πράγματα στη ζωή.
    Ελπίζοντας για το webservice ΠΕΡΙΦΕΡΕΙΑ SOAP κάποια μέρα.
    Με τον τρόπο που η ειδική φοιτητής κέρδισε αργυρό μετάλλιο :)
    φροντίζω

  • @mesfinhaftu6206
    @mesfinhaftu6206 2 роки тому

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

  • @derekbanas
    @derekbanas  11 років тому

    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
    @derekbanas  11 років тому +1

    I'm doing my best to find the perfect speed for these tutorials. Thank you for the input :)

  • @derekbanas
    @derekbanas  11 років тому

    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

  • @SoftwareSimplified-Dtons
    @SoftwareSimplified-Dtons 8 років тому +6

    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.

  • @andreoulis27
    @andreoulis27 7 років тому +4

    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!

  • @derekbanas
    @derekbanas  11 років тому

    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

  • @brandogg
    @brandogg 11 років тому

    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!

  • @derekbanas
    @derekbanas  11 років тому +1

    I'm very happy that I was able to explain it in a way that helped :)

  • @seriouslythodonteven
    @seriouslythodonteven 10 років тому +1

    *****
    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.

    • @kingsob1
      @kingsob1 10 років тому +1

      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.

  • @derekbanas
    @derekbanas  11 років тому

    Thank you very much :) I'm happy that you liked it

  • @derekbanas
    @derekbanas  11 років тому

    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

  • @ChilaquilesZuMittag
    @ChilaquilesZuMittag 11 років тому +1

    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?

  • @tonypepperoni4975
    @tonypepperoni4975 9 років тому +5

    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?

    • @idriskas
      @idriskas 9 років тому +1

      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

    • @GrunnenRocks
      @GrunnenRocks 9 років тому +3

      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

  • @ukaszkazmierczak1816
    @ukaszkazmierczak1816 8 років тому +2

    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.

  • @derekbanas
    @derekbanas  11 років тому +1

    This is just the way I was taught

  • @viranirav
    @viranirav 11 років тому

    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.

  • @derekbanas
    @derekbanas  11 років тому

    Thank you :) Im always here and I'm happy to answer any questions you have

  • @samtux762
    @samtux762 8 років тому +1

    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?

  • @derekbanas
    @derekbanas  11 років тому

    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

  • @SabrinaMarkon
    @SabrinaMarkon 7 років тому

    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.

  • @OmoruyiOmofonmwan
    @OmoruyiOmofonmwan 4 роки тому

    Quick question. What if multiple Nodes have the same key? How do we bypass that?

  • @dritanmuslia6922
    @dritanmuslia6922 2 роки тому

    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.

  • @stevenchuang9897
    @stevenchuang9897 10 років тому +2

    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 ;)

  • @sumeetpande6504
    @sumeetpande6504 9 років тому

    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 ?

  • @archiliusfowl3701
    @archiliusfowl3701 11 років тому

    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.

  • @krishnareddyk8425
    @krishnareddyk8425 9 років тому

    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;
    }

  • @MYMOMISAMAZING1
    @MYMOMISAMAZING1 7 років тому

    Derek you just got yourself a new subscriber this will get me through cs. You're a lifesaver!! keep up the videos :)

    • @derekbanas
      @derekbanas  7 років тому

      Thank you :) I'm very happy to be of help

  • @norcal6181
    @norcal6181 8 років тому +5

    Hey Derek, I am wondering if you plan on doing a video on AVL trees, or balanced binary search trees?

    • @derekbanas
      @derekbanas  8 років тому +8

      +Philthy Phil Yes that is coming soon

    • @BlackSanta22
      @BlackSanta22 8 років тому +1

      Yes please would love to see a video on it thanks :D

    • @suhyunkim3972
      @suhyunkim3972 8 років тому

      I'm waiting here too

  • @architchawla6278
    @architchawla6278 4 роки тому

    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?

  • @CamsterClips
    @CamsterClips 8 років тому

    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!

  • @CelticSongbird9642
    @CelticSongbird9642 6 років тому

    You left the light on for me!

    • @derekbanas
      @derekbanas  6 років тому

      Thank you for the compliment :)

  • @piyush_ramnani
    @piyush_ramnani 9 років тому

    You explained it in the best way possible. :)
    Thanks Derek Banas

    • @derekbanas
      @derekbanas  9 років тому

      Piyush Ramnani Thank you for the compliment :) I'm glad I could help.

  • @calisurfer619
    @calisurfer619 9 років тому

    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?

  • @sumitrathore3796
    @sumitrathore3796 9 років тому +11

    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 .. :)

    • @derekbanas
      @derekbanas  9 років тому +2

      Sumit Rathore You're very welcome :) Sorry about the speed I'm working on it

    • @zacharycollins2209
      @zacharycollins2209 9 років тому +2

      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.

  • @dharmikkachhia1640
    @dharmikkachhia1640 11 років тому

    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.

  • @viranirav
    @viranirav 11 років тому

    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?

  • @caseyscarborough
    @caseyscarborough 11 років тому

    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!

  • @MrBarla1
    @MrBarla1 7 років тому +4

    Love your videos Derek.
    One error:
    Line 235 should be:
    parent.rightChild = focusNode.rightChild;

    • @derekbanas
      @derekbanas  7 років тому +4

      Thank you :) Sorry about the error

  • @derekbanas
    @derekbanas  11 років тому

    Thank you very much :) And, thanks for helping others. That is much appreciated

  • @denzosjs
    @denzosjs 5 років тому

    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.

  • @xiangmingju6293
    @xiangmingju6293 11 років тому

    Hi Derek, why you replace the deleted node with the right child. why not the rightmost node in the left subtree?

  • @yaz0333
    @yaz0333 7 років тому

    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?

  • @ToDeoS
    @ToDeoS 9 років тому

    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.

    • @derekbanas
      @derekbanas  9 років тому

      Jiemin Xi Your welcome :) Yes you are correct that this is a binary search tree

  • @arnekristiankittelsen2693
    @arnekristiankittelsen2693 9 років тому

    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"

  • @qwe123727
    @qwe123727 9 років тому

    Derek,
    I wish, I would see your lectures on Red black trees and graphs

    • @derekbanas
      @derekbanas  9 років тому +1

      Ethashamuddin Mohammed I'm hoping to cover those very soon.

    • @qwe123727
      @qwe123727 9 років тому

      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!!!

  • @ajeshmahto4390
    @ajeshmahto4390 8 років тому

    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.

  • @mohammadomer147
    @mohammadomer147 10 років тому

    i dont know why i can't see anyone better than you derek ^_^ thank u again my teacher

    • @derekbanas
      @derekbanas  10 років тому +1

      mohammad omer Thank you for the nice message :) I'm very happy I could help

  • @PressStartLetsPlay
    @PressStartLetsPlay 9 років тому +1

    Awesome tutorial as always :) These really help aiding me with my data structures class.

    • @derekbanas
      @derekbanas  9 років тому

      Cheaper Thank you :) I'm happy that I could help

  • @TheRickman93
    @TheRickman93 10 років тому

    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!!

  • @dingding31120
    @dingding31120 10 років тому

    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?

    • @derekbanas
      @derekbanas  10 років тому

      Pento Tom This should help docs.oracle.com/javase/7/docs/api/java/util/TreeSet.html

  • @AcesSkandi005
    @AcesSkandi005 10 років тому

    How to create Java program for
    Are two Binary Trees mirror image of each other?
    Coding in Java Eclipse Please help me

  • @rajveerajmani
    @rajveerajmani 2 місяці тому

    Thanks for this video man, so helpful🤗🤗🤗

  • @Co0lGwindolyn
    @Co0lGwindolyn 4 роки тому

    You didn't explain the basis of deleting and how we choose the replacement for the node ..

  • @FreuleinN
    @FreuleinN 10 років тому

    Thank you so much Derek! Your videos are just awesome, you can't imagine HOW MUCH they help me (and many many others)! :)

    • @derekbanas
      @derekbanas  10 років тому

      FreuleinN Thank you for the kind note :) I greatly appreciate it.

  • @sudiptaa6159
    @sudiptaa6159 7 років тому

    Great style of teaching . Thank you :)

  • @dilpreetb8907
    @dilpreetb8907 5 років тому

    You sound like Andy from the office, great video thanks!

  • @jessfarmer6667
    @jessfarmer6667 10 років тому +1

    Do you still plan on creating a video for Red-Black Binary Search Trees?

    • @derekbanas
      @derekbanas  10 років тому

      Jess Farmer I hope to cover advanced algorithms at some point. I want to properly cover Android first though.

    • @jessfarmer6667
      @jessfarmer6667 10 років тому +1

      Derek Banas Well that's great, thanks for taking the time to create these videos. You're the man!

  • @andrewmartin4045
    @andrewmartin4045 7 років тому

    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

    • @derekbanas
      @derekbanas  7 років тому

      Thank you for the input :)

  • @gk77ful
    @gk77ful 9 років тому

    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!!

  • @the2hg442
    @the2hg442 2 роки тому

    What about generic ?

  • @shobyvinci
    @shobyvinci 9 років тому

    very helpful video but algo cant remove the actual root :/
    not sure why...

  • @TheoryAndGames
    @TheoryAndGames 9 років тому

    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.

    • @ruialves92
      @ruialves92 9 років тому

      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.

  • @derekbanas
    @derekbanas  11 років тому

    Ένα ακόμα video αλγόριθμος και στη συνέχεια θα ξεκινήσει το Android. Θα πρέπει να καλύπτει πολλά από τα θέματα που έχουν ζητήσει. Χαίρομαι που εσείς απολαμβάνετε τα βίντεο

    • @Sublime45
      @Sublime45 6 років тому +1

      Is this comment in greek or does youtube autotranslated it just to mess with me?

  • @derekbanas
    @derekbanas  11 років тому

    Thank you :) You're very kind

  • @Hrathen39
    @Hrathen39 7 років тому

    i noticed in the beginning you didnt address the issue of when deleting a node that has 2 children which are both subtrees

  • @dangray1152
    @dangray1152 10 років тому

    Thank you so much for this! Was having a hard time with the deletion!

    • @derekbanas
      @derekbanas  10 років тому

      You're very welcome :)

    • @dangray1152
      @dangray1152 10 років тому

      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?

    • @dangray1152
      @dangray1152 10 років тому

      Random ordered numbers do work though!

    • @dangray1152
      @dangray1152 10 років тому

      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

    • @dangray1152
      @dangray1152 10 років тому

      Dan Gray I read the further comments and went to your site and got the code there. Works perfectly! Again, thanks again!

  • @jyotsnamalladi2727
    @jyotsnamalladi2727 10 років тому

    Very clear!!! thank you derek

  • @xiaodongyang7927
    @xiaodongyang7927 10 років тому

    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.

    • @xiaodongyang7927
      @xiaodongyang7927 10 років тому

      BTW,I really enjoy your tutorials. I love your code style and explicit thoughts.

    • @derekbanas
      @derekbanas  10 років тому

      Xiaodong Yang Thank you :)

  • @lovenhalecavite8422
    @lovenhalecavite8422 11 років тому

    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 -_-

  • @Bl4cKR0xX
    @Bl4cKR0xX 8 років тому

    Thank you ver much for this.
    Helps me understand those things once again, since I'm a little bit out of practice :)

    • @derekbanas
      @derekbanas  8 років тому

      +Bl4cKR0xX You're very welcome :)

  • @michaelngangom428
    @michaelngangom428 9 років тому

    Hi Derek! Thanks for the great video tutorial...I just wanted to ask if this is binary search tree..not just binary tree?

    • @derekbanas
      @derekbanas  9 років тому

      michael ngangom You're very welcome :) Yes this is a binary search tree.

  • @zbcuber2465
    @zbcuber2465 9 років тому

    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 :)

    • @derekbanas
      @derekbanas  9 років тому

      ZBCuber Have you seen this stackoverflow.com/questions/2694005/write-to-file-binary-search-tree

    • @zbcuber2465
      @zbcuber2465 9 років тому

      ahh, that is useful, thankyou

  • @davethatcher2229
    @davethatcher2229 9 років тому

    Derek,
    Have you done any videos that cover counting leaves or counting nodes using recursion?

    • @derekbanas
      @derekbanas  9 років тому

      Dave Thatcher I have not done that specifically, but I have a recursion tutorial

  • @arunsasidharannambiar
    @arunsasidharannambiar 11 років тому

    Hi Derek,
    I am a little confused. What if the right child of the node to be deleted has two children?

  • @deodeveloper
    @deodeveloper 10 років тому

    We are deleting root node, 50. Now What if 75 has a left node?

    • @samtux762
      @samtux762 8 років тому

      You would find leftmost child of 75.

  • @milankyoolbaba8420
    @milankyoolbaba8420 4 роки тому

    You have done a mistake at time 8.19 that is you have to write parent.rightchild=focusNode.rightchild; line number 235

  • @ivanshlomin615
    @ivanshlomin615 7 років тому

    Can you change it? Thx

  • @randb9378
    @randb9378 4 роки тому

    what do you mean by setting the root node to null on 5:56?
    how can the root node be null?

    • @ApoorvTheSinghai
      @ApoorvTheSinghai 3 роки тому

      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

  • @derekbanas
    @derekbanas  11 років тому

    Muchas gracias :)

  • @derekbanas
    @derekbanas  11 років тому

    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.

  • @shaynetee3560
    @shaynetee3560 8 років тому

    do you have any avl implementation?

  • @nolan.is.coding
    @nolan.is.coding 10 років тому

    Your tutorials on binary Search tree are very good. Do you know a good one about red black trees ? In order to balance trees.

    • @derekbanas
      @derekbanas  10 років тому

      Thank you :) No I don't but I plan on making one as soon as I get a chance.

  • @fnote9286
    @fnote9286 8 років тому +8

    IF 75 had a left child what will happen when deleting 50

    • @arshad887
      @arshad887 7 років тому +2

      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

    • @brunok7270
      @brunok7270 4 роки тому

      @@arshad887 this really helped

  • @Kayserctv
    @Kayserctv 11 років тому

    Could you make a tutorial on how to make a custom PC?

  • @kalinvstr
    @kalinvstr 6 років тому

    2:00 whatever child you move what if it has its own left and right already

  • @stebu92
    @stebu92 11 років тому

    do you plan to cover treaps?

  • @MrSauce714
    @MrSauce714 9 років тому

    this guy is so great ! Thank you for this .....

  • @agnibhachakz
    @agnibhachakz 6 років тому

    Please explain the code inside the getReplacementNode method.

    • @ytg6663
      @ytg6663 6 років тому

      Agnibha Chakraborty yes