Binary Search Trees - Print Children Function - C++ - Part 8

Поділитися
Вставка
  • Опубліковано 4 бер 2014
  • In this tutorial, we take a closer look at the binary search tree by writing a PrintChildren() function that displays the children of a parent node.
    Want to learn C++? I highly recommend this book amzn.to/1PftaSt
    Donate - bit.ly/17vCDFx
    STILL NEED MORE HELP?
    Connect one-on-one with a Programming Tutor. Click the link below:
    trk.justanswer.com/aff_c?offe...
    :)

КОМЕНТАРІ • 19

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

    Programming never seemed this easy to me. Thanks a lot!

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

    Nice video, in case viewers are reading my comment I think the best way to handle the case if the root is NULL for the returnRoot function is to throw an exception instead of returning -1000. If you want to prove me wrong that is great.

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

    Love you, Paul! :)

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

    Excellent, Thank you !

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

    dude you're awesome, thanks A LOT

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

    need your help Paul and other programmers... i have a school assignment that the task is to preorder math expression to inorder using binary trees ... my knowledge in c++ on BST is very very basic and i am keep reading but couldnt find a specific algorithm to this specific task.... any help is welcome :)

  • @mtpk_
    @mtpk_ 5 років тому +4

    One dislike is from struct

    • @cjeeckazad2995
      @cjeeckazad2995 3 роки тому +1

      stii one ☝️

    • @mtpk_
      @mtpk_ 3 роки тому +2

      @@cjeeckazad2995 lol actually? woah there is only one dislike :O

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

    My man.

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

    I know this video is kinda old but i am getting repeats of the first element in array and the Conditional ? isn't working for me

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

    Hey, I just wanted to ask, if anyone could help me figure out, why my left and right children keys are the same for every node. The key values are the same as the root children key values. Parent nodes key outputs themselves are ok.
    So it goes like this:
    Parent Node = 76
    Left Child = 21
    Right Child = 76
    Parent Node = 4
    Left Child = 21
    Right Child = 76
    Thanks in advance!

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

      Nevermind, just an absence of the second "=" symbol. D-:

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

    How would I get it to print the entire tree if a user is adding nodes one at a time?

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

      +Boricuakriz u can place InOrderTraversal function inside the function that adds new item to the tree and every time u will see the updated tree

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

    Hi, I have the same code as Paul, but only the root node's children are printed. Others say the key is not in the tree. I already cross checked my code with what Paul wrote multiple times, but I keep getting the same result. PLS HELP!!!!!!!!!!!
    I thought the problem might me with my "return-node".
    //**********SEARCH-PRIV************//
    BST::node* BST::SearchPriv(int key, node* ptr){
    if(ptr != NULL){
    if(ptr->key == key){
    cout

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

      You have the following:
      else{
      if(ptr->key < key)
      return SearchPriv(key, ptr->left);
      else
      return SearchPriv(key, ptr->right);
      }
      It should be like this:
      else{
      if(key < ptr->key)
      return SearchPriv(key, ptr->left);
      else
      return SearchPriv(key, ptr->right);
      }
      Hopefully, this helps.

    • @Dalton-xz3rd
      @Dalton-xz3rd Місяць тому

      2:42 😅 I can come over and play with my house if that helps with the first time we can get the next one we have a new one in the ​@@hani4153046