Binary Trees in Python: Introduction and Traversal Algorithms

Поделиться
HTML-код
  • Опубликовано: 11 мар 2018
  • This video is sponsored by Oxylabs. Oxylabs provides market-leading web scraping solutions for large-scale public data gathering. You can receive data in JSON or CSV format and pay only per successful request. At the moment, Oxylabs offers a free trial.
    oxylabs.io/?...
    In this video, we will go over the binary tree data structure. We then go over how to implement this data structure in Python. We then cover the three recursive depth-first search traversal algorithms (preorder, inorder, and postorder) and implement those recursively in Python.
    The software written in this video is available at:
    github.com/vprusso/youtube_tu...
    The slides for this video can be found here:
    drive.google.com/open?id=1OPq...
    Do you like the development environment I'm using in this video? It's a customized version of vim that's enhanced for Python development. If you want to see how I set up my vim, I have a series on this here:
    bit.ly/lp_vim
    If you've found this video helpful and want to stay up-to-date with the latest videos posted on this channel, please subscribe:
    bit.ly/lp_subscribe

Комментарии • 448

  • @LucidProgramming
    @LucidProgramming  5 лет назад +103

    Note that @26:30 I call the "inorder" traversal function inside of the "postorder" traversal function and neglected to change it to postorder. This was a copy-paste error. You can fix it by changing the "inorder" call in postorder to the appropriate postorder call. Sorry for the mistake, and thanks for watching!

    • @Soccercrazyigboman
      @Soccercrazyigboman 5 лет назад

      How can you go from child back to parent if you don't have a next and previous pointer?

    • @Soccercrazyigboman
      @Soccercrazyigboman 5 лет назад

      By next and previous I should say if each node doesnt have a pointer pointing to the one above it as well as to the one below it?

    • @AshwaniKumar-dj6re
      @AshwaniKumar-dj6re 5 лет назад

      @@Soccercrazyigboman he is using recursion

    • @NicholasSilva1380
      @NicholasSilva1380 5 лет назад +40

      That changes the expected output from 4-2-5-6-3-7-1- to 4-5-2-6-7-3-1-

    • @violetkimani3118
      @violetkimani3118 5 лет назад

      Hi, would be more efficient to add a function from within the class for adding values to the tree? does it help/ would it be more efficient especially during interviews

  • @chrisgoehl2745
    @chrisgoehl2745 4 года назад +5

    Great Video! Thank you for visualising and really emphasizing on the most basic aspects as this is something which I personally as a Beginner seem to struggle with!
    Keep up the good work it is really appreciated!

    • @LucidProgramming
      @LucidProgramming  4 года назад +1

      Thanks, Chris! That feedback is really helpful for me and I will try to keep that in mind for future videos. Thanks again for watching and for the comment!

  • @safderaree
    @safderaree 5 лет назад +6

    Hands down the best explanation, I've struggled for so long trying to get the intuition through my textbook. Thanks!

    • @LucidProgramming
      @LucidProgramming  5 лет назад +1

      Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing! I really appreciate the support. I hope that the content I provide there will enhance the videos on my RUclips page.
      bit.ly/lp_email

    • @safderaree
      @safderaree 5 лет назад +1

      @@LucidProgramming Sure, I've subscribed and signed up for the mailing list. You've made my interviewing process so much smoother.

    • @LucidProgramming
      @LucidProgramming  5 лет назад

      @@safderaree Awesome, that's really great to hear! :)

  • @bhaskarbhuyan30
    @bhaskarbhuyan30 4 года назад +4

    Very informative and easy-to-understand tutorial. Thank you for this incredible contribution to the enthusiasts and learners!

    • @LucidProgramming
      @LucidProgramming  4 года назад

      Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing!
      I really appreciate the support, and if you want to support the channel, I do have a PayPal link (www.paypal.me/VincentRusso1) for donations that go directly to the creation of content on this channel.
      I hope that the content I provide there will enhance the videos on my RUclips page.
      bit.ly/lp_email

  • @user-ru2gn4uw4z
    @user-ru2gn4uw4z Год назад

    Большое спасибо за ваше видео)
    Это потрясающе, я посмотрел ваш Гайд по связным спискам и теперь я тут. Лучшие видео по этой теме!)

  • @turjo119
    @turjo119 3 года назад +9

    I was stuck for hours trying to understand this, you made it so simple! Thank you so much

    • @LucidProgramming
      @LucidProgramming  3 года назад +3

      Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!

    • @turjo119
      @turjo119 3 года назад +2

      @@LucidProgramming Done and done my good man!

    • @LucidProgramming
      @LucidProgramming  3 года назад +1

      @@turjo119 Cheers, thank you!

  • @rhythmsaparia8788
    @rhythmsaparia8788 4 года назад +4

    Your explanation to data structure concepts in python is THE best!

    • @LucidProgramming
      @LucidProgramming  4 года назад

      Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing!
      I really appreciate the support, and if you want to support the channel, I do have a PayPal link (www.paypal.me/VincentRusso1) for donations that go directly to the creation of content on this channel.
      I hope that the content I provide there will enhance the videos on my RUclips page.
      bit.ly/lp_email

  • @reccartoon
    @reccartoon 5 лет назад +2

    i really love the way you are explaining all these concepts in very effective manner thanks for this :)

    • @LucidProgramming
      @LucidProgramming  5 лет назад

      Hi Sarfaraz. Really appreciate that comment, that's very much appreciated! Thank you for watching, and I'm happy to hear this video was effective. Cheers!

  • @bijayamanandhar3890
    @bijayamanandhar3890 4 года назад +17

    Thank you for the great tutorial! I am a new developer still looking for a job after graduation from a boot camp. I never had a chance to learn the data-structure, dfs, bfs etc before. Now, it's getting clear to me step by step after watching the videos you posted.

    • @LucidProgramming
      @LucidProgramming  4 года назад +2

      Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing!
      I really appreciate the support, and if you want to support the channel, I do have a PayPal link
      paypal.me/VincentRusso1
      for donations that go directly to the creation of content on this channel.
      I hope that the content I provide there will enhance the videos on my RUclips page.
      bit.ly/lp_email

  • @muhammadsalisabdulsalam4016
    @muhammadsalisabdulsalam4016 5 лет назад +2

    This is the most simplified video tutorial with good examples, the best I have seen so far. I got everything after watching this video only once. A lot of online tutorials are just too ambiguous and really confusing. Lucid you're the best for sure. Thanks a lot

    • @LucidProgramming
      @LucidProgramming  5 лет назад +2

      Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing!
      I really appreciate the support, and if you want to support the channel, I do have a PayPal link (www.paypal.me/VincentRusso1) for donations that go directly to the creation of content on this channel.
      I hope that the content I provide there will enhance the videos on my RUclips page.
      bit.ly/lp_email

    • @muhammadsalisabdulsalam4016
      @muhammadsalisabdulsalam4016 5 лет назад +1

      @@LucidProgramming Sure, I'm interested. But how do I subscribe to your mail list please?

    • @LucidProgramming
      @LucidProgramming  5 лет назад +2

      @@muhammadsalisabdulsalam4016 Just follow the link here: bit.ly/lp_email
      :)

  • @hassanfarah3501
    @hassanfarah3501 4 года назад +1

    God bless you Sir. I have been following your tutorials for a while and you are a LEGEND

    • @LucidProgramming
      @LucidProgramming  4 года назад

      Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing!
      I really appreciate the support, and if you want to support the channel, I do have a PayPal link www.paypal.me/VincentRusso1
      for donations that go directly to the creation of content on this channel.
      I hope that the content I provide there will enhance the videos on my RUclips page.
      bit.ly/lp_email

  • @enkaibi2756
    @enkaibi2756 5 лет назад +3

    Too excited to sleep now! I finally understand it! Best video on Traversal Algorithms explanation! Consider watching all your python video!

    • @LucidProgramming
      @LucidProgramming  5 лет назад

      Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing!
      I really appreciate the support, and if you want to support the channel, I do have a PayPal link (www.paypal.me/VincentRusso1) for donations that go directly to the creation of content on this channel.
      I hope that the content I provide there will enhance the videos on my RUclips page.
      bit.ly/lp_email

    • @enkaibi2756
      @enkaibi2756 5 лет назад +3

      @@LucidProgramming Just a tiny recommendation, on 17:06, it would be better to use self.root instead of tree .root. Keep going! !!

    • @LucidProgramming
      @LucidProgramming  5 лет назад

      @@enkaibi2756 Point well taken. Thanks for the comment! :)

  • @vishnukumavat7489
    @vishnukumavat7489 4 года назад +1

    Thanks for such a cool implementation explanation.

    • @LucidProgramming
      @LucidProgramming  4 года назад

      Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. I hope to be putting out more similar videos soon!

  • @theguildedcage
    @theguildedcage 5 лет назад +2

    Awesome tutorial! Thanks.

    • @LucidProgramming
      @LucidProgramming  5 лет назад

      Thank you, Philip! I'm glad you found the tutorial useful! Cheers, and thanks again for watching.

  • @DavidKaplanProgramming
    @DavidKaplanProgramming 5 лет назад +1

    Really good tutorial man! Thanks

    • @LucidProgramming
      @LucidProgramming  5 лет назад

      Thank you, David, I'm very happy to hear that you enjoyed the tutorial! Cheers.

  • @jethrotalavera3314
    @jethrotalavera3314 2 года назад +1

    Best video I've seen on this topic. Thank you!

    • @LucidProgramming
      @LucidProgramming  2 года назад

      Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!

  • @Rich65501
    @Rich65501 4 года назад +2

    Beautiful presentation.

    • @LucidProgramming
      @LucidProgramming  4 года назад

      Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing!
      I really appreciate the support, and if you want to support the channel, I do have a PayPal link (www.paypal.me/VincentRusso1) for donations that go directly to the creation of content on this channel.
      I hope that the content I provide there will enhance the videos on my RUclips page.
      bit.ly/lp_email

  • @ramiz3570
    @ramiz3570 4 года назад +1

    Amazing explanation, thanks!

    • @LucidProgramming
      @LucidProgramming  4 года назад

      Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing!
      I really appreciate the support, and if you want to support the channel, I do have a PayPal link (www.paypal.me/VincentRusso1) for donations that go directly to the creation of content on this channel.
      I hope that the content I provide there will enhance the videos on my RUclips page.
      bit.ly/lp_email

  • @isaacobiri1407
    @isaacobiri1407 5 лет назад +1

    Thank you so much for the great tutorial!!

    • @LucidProgramming
      @LucidProgramming  5 лет назад

      Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing! I really appreciate the support. I hope that the content I provide there will enhance the videos on my RUclips page.
      bit.ly/lp_email

  • @zarioiubogdan1164
    @zarioiubogdan1164 3 года назад +1

    Hi there!
    Thank you so much for this! I just discovered your videos and they are so helpful! I was struggling a lot to understand how I could implement and traverse a binary tree. There are countless videos about this but yours really made me understand and gave me hope that with time and practice I could learn these concepts.
    I saw you have videos on many data structures and I plan to go through all of them and try to understand. Could you please also cover graph implementation and traversal in Python?
    Thank you again for your help!
    Wish you the best!

    • @LucidProgramming
      @LucidProgramming  3 года назад +1

      You can feel free to make suggestions on my Patreon page. This would streamline what you want to see and also help to support my channel.
      www.patreon.com/lucidprogramming

  • @bhuwansharmaa
    @bhuwansharmaa 4 года назад +1

    Best Explanation
    recursion is bit confusing but following each step through example made it easy... Thanks

    • @LucidProgramming
      @LucidProgramming  4 года назад +1

      Awesome, that's great to hear. Thanks for watching!

  • @hoangphuoccao117
    @hoangphuoccao117 2 года назад +1

    Great explanations! Thank you very much!!

    • @LucidProgramming
      @LucidProgramming  2 года назад +1

      Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!

  • @nx8221
    @nx8221 4 года назад +3

    Dude thank you for this!

    • @LucidProgramming
      @LucidProgramming  4 года назад +1

      Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing!
      I really appreciate the support, and if you want to support the channel, I do have a PayPal link (www.paypal.me/VincentRusso1) for donations that go directly to the creation of content on this channel.
      I hope that the content I provide there will enhance the videos on my RUclips page.
      bit.ly/lp_email

  • @edgarlip2
    @edgarlip2 4 года назад +4

    wow - it is awesome !!!
    i can tell one analogy that helped me a lot : when do i collect the value :
    • pre-order - when value collected ?: once I am hovering on a node I am collecting it's value.
    • in-order - when value collected ?: if the node has no left node or the left node is already visited then add this value.
    • post-order - when value collected ?: once the node has no left nor right or left and right has been already visited then I will collect the value.
    HTH

    • @LucidProgramming
      @LucidProgramming  4 года назад

      Thanks, and yes that's a great way to remember them!

  • @felipepardosuarez2364
    @felipepardosuarez2364 5 лет назад +2

    Great video. Thank you!

    • @LucidProgramming
      @LucidProgramming  5 лет назад

      Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing! I really appreciate the support. I hope that the content I provide there will enhance the videos on my RUclips page.
      bit.ly/lp_email

  • @musclecode3771
    @musclecode3771 4 года назад +1

    Amazing explanation well worth the time to watch.

    • @LucidProgramming
      @LucidProgramming  4 года назад

      Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. I hope to be putting out more similar videos soon!

  • @dmgisi
    @dmgisi Год назад +3

    I appreciate the good video and clear explanation. With a little more editing and attention to detail, it can become more polished and will be excellent.

    • @LucidProgramming
      @LucidProgramming  Год назад

      Thank you! I hope that the videos on this channel keep getting progressively better. Thanks for watching!

  • @HanisaMohamed
    @HanisaMohamed 3 года назад +1

    Thank you! Explained it very well.

    • @LucidProgramming
      @LucidProgramming  3 года назад +1

      Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!

  • @carsonisgayandugly
    @carsonisgayandugly 4 года назад +2

    Hi, thank you so much for the video. I am a little confused still about one thing. When in the preorder traversal, when it comes to a leaf that dosn't have a left or right node, in the code how does it go backwards to the previous node or back to the root?

    • @LucidProgramming
      @LucidProgramming  4 года назад +3

      I would encourage you to check out my playlist on recursion, as it seems you have a gap in understanding how recursive calls are treated.

  • @wikhan2002
    @wikhan2002 4 года назад

    Awesome! Just Awesome! This is where I could navigate to learn such an important thing earlier.

  • @SaltAndVi
    @SaltAndVi 3 года назад +1

    phenomenal video, thank you so much!!!

    • @LucidProgramming
      @LucidProgramming  3 года назад

      Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!

  • @vnpikachu4627
    @vnpikachu4627 6 лет назад +1

    Great work very easy to understand i really appreciate what you are doing to help us

    • @LucidProgramming
      @LucidProgramming  6 лет назад

      Hey Huru. Thank you very much for that comment. It's really great to hear that these videos have been helpful to you. I really get a lot of enjoyment from doing so as well, so the benefit is mutual! Cheers and thanks again for watching.

    • @vnpikachu4627
      @vnpikachu4627 6 лет назад +1

      Just 30 minutes i go from nothing to understand a lot more about tree could you please make a tutorial about graph and some algorithm about tree ?

    • @LucidProgramming
      @LucidProgramming  6 лет назад

      Really happy to hear that. Yes, graphs are most certainly coming up soon! Thanks for the suggestion and for the comment!

  • @ilanaizelman3993
    @ilanaizelman3993 2 года назад +1

    Can't be explained better. Thank you!

    • @LucidProgramming
      @LucidProgramming  2 года назад +1

      Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!

    • @ilanaizelman3993
      @ilanaizelman3993 2 года назад

      @@LucidProgramming Done! :)
      Are you during Mock Interviews?
      Or know someone who does?

    • @LucidProgramming
      @LucidProgramming  2 года назад

      @@ilanaizelman3993 Thank you, Ilan! Your support is very much appreciated! And yes, I do perform mock interviews, coaching, and consulting services for software-based job preparation. If you're interested in setting something up, you're free to reach out to me in the "About" section of my channel and we can coordinate from there if you like. Cheers, and best of luck in your preparation in any case!

  • @khavishbhundoo3792
    @khavishbhundoo3792 6 лет назад +1

    Could you include the link for the presentation as well.It serves as a quick recap.Thanks for the great explanation.

    • @LucidProgramming
      @LucidProgramming  6 лет назад +1

      At the moment, those slides are a bit all over the place. However, it would certainly not be an issue to clean them up and post a link in the description of this video. Might take me a while to get around to it, but I'll add it to the list. Thanks for the suggestion and thanks for watching! :)

  • @rohith8269
    @rohith8269 3 года назад +1

    great explanation!!

    • @LucidProgramming
      @LucidProgramming  3 года назад

      Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!

  • @hussainaqeel7371
    @hussainaqeel7371 2 года назад +1

    Great Stuff! Made it very easy to understand! Thanks!

    • @LucidProgramming
      @LucidProgramming  2 года назад

      Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!

    • @hussainaqeel7371
      @hussainaqeel7371 2 года назад

      @@LucidProgramming sure!

    • @LucidProgramming
      @LucidProgramming  2 года назад

      @@hussainaqeel7371 Cheers, thank you!

  • @nero9985
    @nero9985 3 года назад

    Thank god I looked at the comments regarding the issue with the post order function, I spent a good 10 mins looking to see if I had the wrong implementation

    • @LucidProgramming
      @LucidProgramming  3 года назад

      Glad you caught that, and sorry for the trouble!

  • @emadharazi5044
    @emadharazi5044 4 года назад

    Amazing video. Thank you very much. I just have one question. Is it possible to get a string of the tree using the inorder function but with only using one argument instead of two?

  • @olivierbegassat851
    @olivierbegassat851 4 года назад +1

    Very valuable explanation! Thanks : )

    • @LucidProgramming
      @LucidProgramming  4 года назад

      Glad to hear it, and thanks for watching! :)

    • @olivierbegassat851
      @olivierbegassat851 4 года назад

      ​@@LucidProgramming The preorder_print function is the sort of thing I would have had a hard time coming up with myself. My naïve attempt would have been to have some list or dictionary of nodes whose left child you've already visited ... instead you simply wrote (amongst other things I'm skipping)
      traversal = self.preorder_print(start.left, traversal)
      traversal = self.preorder_print(start.right, traversal)
      This is really interesting, it's orders of magnitude more elegant and succinct. I wouldn't have come up with it. I would have written some longwinded solution using an extra list or dictionary.
      Do you know a book or online resource that contains Python implementations of many standard data structures ?

    • @LucidProgramming
      @LucidProgramming  4 года назад

      @@olivierbegassat851 Thanks for the comment. Honestly, you can probably just Google for Python data structures and find something reasonably good.

  • @raakobihai2967
    @raakobihai2967 3 года назад +1

    Thank you soo much for this!

    • @LucidProgramming
      @LucidProgramming  3 года назад

      Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!

  • @hemesh5663
    @hemesh5663 2 года назад +1

    Dude you earned a subscriber and a fan

    • @LucidProgramming
      @LucidProgramming  2 года назад

      Thank you, man! Sincerely appreciate the support and love! Cheers!

  • @CodeX-mhs
    @CodeX-mhs Месяц назад +1

    Extremely thankful to you sir.

    • @LucidProgramming
      @LucidProgramming  Месяц назад +1

      Thank you for the kind words, glad the videos are useful for you!

    • @CodeX-mhs
      @CodeX-mhs Месяц назад

      @@LucidProgramming A very welcome sir. Please keep providing. The growth doesn’t justify ur quality. Keep it up sir.

  • @valentynsson5969
    @valentynsson5969 4 года назад +2

    Legend perfect explanation thank´s I like it.

    • @LucidProgramming
      @LucidProgramming  4 года назад +1

      Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing!
      I really appreciate the support, and if you want to support the channel, I do have a PayPal link
      paypal.me/VincentRusso1
      for donations that go directly to the creation of content on this channel.
      I hope that the content I provide there will enhance the videos on my RUclips page.
      bit.ly/lp_email

  • @wyllerdesousa1710
    @wyllerdesousa1710 Год назад +1

    Nice introduction! Thanks to support the TI community.

  • @toderickson6106
    @toderickson6106 2 года назад +1

    good clarification skills, gave it a like

    • @LucidProgramming
      @LucidProgramming  2 года назад

      Very much appreciated--thank you for the support!

  • @jayaramakapil5295
    @jayaramakapil5295 4 года назад +20

    All Superheroes don't Wear Capes. Some wear Suit too :)

    • @LucidProgramming
      @LucidProgramming  4 года назад +4

      Haha, well I hope the videos are helpful to you. Cheers, and thanks for watching!

  • @hakankanplay
    @hakankanplay 5 лет назад

    can you explain @19:33 when you call return tranversal, why it returns you the previous node of the current node that has empty left and right childs?

    • @LucidProgramming
      @LucidProgramming  5 лет назад +1

      Hi Hakan. Sure, the reason for this is because as we hit the base case of the function, we start working back through the stack frame from all the previous recursive calls to the function. I would recommend you print out the output as these calls are being made to see when and where they happen. I think seeing that can be helpful. Hope that makes sense, and thanks for watching!

  • @kowyo
    @kowyo 18 дней назад

    Thank you for this video

  • @deojeetsarkar2006
    @deojeetsarkar2006 4 года назад +6

    Your videos deserve more views

    • @LucidProgramming
      @LucidProgramming  4 года назад +1

      Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing!
      I really appreciate the support, and if you want to support the channel, I do have a PayPal link (www.paypal.me/VincentRusso1) for donations that go directly to the creation of content on this channel.
      I hope that the content I provide there will enhance the videos on my RUclips page.
      bit.ly/lp_email

  • @gargoth
    @gargoth 4 года назад +1

    great video! i would suggest matching the colors of the slides to the colors of the editor, because the sudden switch from dark to light doesn't sit well while watching. thanks!

    • @LucidProgramming
      @LucidProgramming  4 года назад +1

      Thanks for the feedback, that's very helpful to know! Thanks again for watching as well!

    • @gargoth
      @gargoth 4 года назад +1

      no problem dude, i really appreciate your videos!

    • @LucidProgramming
      @LucidProgramming  4 года назад +1

      @@gargoth Cheers, thank you!

  • @DanielGarcia-uq8yz
    @DanielGarcia-uq8yz Год назад +1

    I'm only 3 min in but love the explanations. Thanks!

  • @ishannoying
    @ishannoying 4 года назад +2

    loved it!

    • @LucidProgramming
      @LucidProgramming  4 года назад

      Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing!
      I really appreciate the support, and if you want to support the channel, I do have a PayPal link (www.paypal.me/VincentRusso1) for donations that go directly to the creation of content on this channel.
      I hope that the content I provide there will enhance the videos on my RUclips page.
      bit.ly/lp_email

  • @zewdiherring9528
    @zewdiherring9528 2 года назад +1

    Thanks! Helpful :D

    • @LucidProgramming
      @LucidProgramming  2 года назад

      Thank you for watching, and glad to hear that it was helpful!

  • @ajayprajapati2453
    @ajayprajapati2453 4 года назад

    Hi..Thank you so much for uploading video with nice explanation..

    • @LucidProgramming
      @LucidProgramming  4 года назад

      Cheers! If you found the video helpful, I would definitely appreciate any a like/subscribe/share! Thanks for watching!

  • @Rajgamer22
    @Rajgamer22 2 года назад +1

    very good video for those who want to pick the grasp of binary tree quickly

    • @LucidProgramming
      @LucidProgramming  2 года назад

      Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!

  • @Mankind5490
    @Mankind5490 2 года назад +1

    This is fantastic, thank you

    • @LucidProgramming
      @LucidProgramming  2 года назад +1

      Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!

    • @Mankind5490
      @Mankind5490 2 года назад

      @@LucidProgramming Already done!

  • @MomoDiff48
    @MomoDiff48 2 года назад +1

    Just a small question, is it necessary to make whole class BinaryTree just for the root node? or it has something to do with python versions?

    • @janusztarnowski115
      @janusztarnowski115 Год назад

      Hi. what do you think about it? https: //www.youtube.com/watch? v = xdmijinrk-w

  • @user-vj3fs4cq9n
    @user-vj3fs4cq9n Год назад

    amazing video

  • @piratevv
    @piratevv 4 года назад

    Hi Vincent, excellent as usual. is it possible to traverse iteratively as well? you got some code for us to see?

    • @LucidProgramming
      @LucidProgramming  4 года назад +1

      Of course, anything you can do recursively you can generally do iteratively. I don't have code for it, but I encourage you to try.

  • @jingfenghong2312
    @jingfenghong2312 4 года назад +2

    These are awesome videos I have ever seen. I have a question, why don't you use self.root in print_tree() function, but use tree.root?

    • @LucidProgramming
      @LucidProgramming  4 года назад +1

      Thanks! And either convention is fine there. Using self.root would work just as well. Cheers!

    • @jingfenghong2312
      @jingfenghong2312 4 года назад +1

      @@LucidProgramming Thank you a lot, these videos would definitely help me in my future career interview! I will recommend it to other friends.

    • @LucidProgramming
      @LucidProgramming  4 года назад

      @@jingfenghong2312 Thank you, I sincerely appreciate that!

  • @Me-ex7qg
    @Me-ex7qg 5 лет назад +1

    wish i found your channel earlier. very good

    • @LucidProgramming
      @LucidProgramming  5 лет назад

      Thanks, TJ. I'm happy you stumbled on it now, and I hope the videos serve you well! Thanks for the comment, and happy coding!

  • @hackytech7494
    @hackytech7494 3 года назад +3

    Thank you so much for your explanation it was wonderful. I am having one doubt we haven't coded to go up if we don't have left or right children, then how it goes up programaticaly

    • @LucidProgramming
      @LucidProgramming  3 года назад +1

      Hi Tammay. Thanks for the comment. You might want to check out my recursion playlist if that part is tripping you up. I think it clarifies your confusion. Cheers!

    • @hackytech7494
      @hackytech7494 3 года назад +1

      @@LucidProgramming Ok Thank you so much sir. I will go through that playlist first.

    • @LucidProgramming
      @LucidProgramming  3 года назад +1

      @@hackytech7494 Cheers!

  • @asiacaster3663
    @asiacaster3663 4 года назад

    Im trying to wrap my head around saving the recursive calls in two variables both named traversal in the preorder_print function.. I have spent quite a lot of time learning recursive functions recently (including your videos and others), and thought I understoodd them well for things like binary search and what not, but I still can not picture/map what is going on in my head with those calls in that function, I am getting extremely frustrated right now. Great channel btw, subscribed.

    • @LucidProgramming
      @LucidProgramming  4 года назад

      Recursion is one of those things that I think takes a while in wrapping ones head around. I've worked directly with Sam from Byte-by-Byte and he has some really fantastic material on recursion. Specifically, he provides a free e-book on recursion and dynamic programming that has really great visuals of which I haven't really seen elsewhere. I'd recommend giving that a look.
      And, also, don't get discouraged. Learning these things takes time and practice. Thanks for the support and subscription.

  • @valeriasalas4700
    @valeriasalas4700 3 года назад

    Hello, great video. What if I wanted to create a nested list that represented the tree?

    • @LucidProgramming
      @LucidProgramming  3 года назад +1

      Thanks. I'm not sure how to answer the question. It's kind of like asking "how can I loop over the elements in the tree"? Well, you just use a for loop to do so.

  • @fredirecko
    @fredirecko Год назад

    what is the time complexity of your preorder recursive traversal function?

  • @robn8656
    @robn8656 3 года назад

    Just incase there's someone like me out there: I struggled forever to understand how this code and recursive data structures generally worked until I finally understood recursion. Al Sweigart has a great video on recursion but essentially recursive functions use a stack method to determine how the functions are called. the subsequent functions can't be called until the previous one has been removed from the stack. each number being appended to the string is that function being removed from the stack. So, counterintuitively, the string begins with one because it's the LAST METHOD to be cleared from the stack. All, the other methods cycle through the tree first, appending their value to the string. It sounds backwards, I know. I don't even know if I explained it well but you have to understand recursion to understand BST. Watch Sweigart's video.

    • @LucidProgramming
      @LucidProgramming  3 года назад

      Cool, thanks for sharing and thanks for watching!

  • @yashpandey350
    @yashpandey350 4 года назад +3

    Sir in each order_print functions how node gets back to head position when its left child or right child becomes None.

    • @LucidProgramming
      @LucidProgramming  4 года назад

      Through the recursive call of the function (if I understand the question correctly).

    • @ajrvasu
      @ajrvasu 3 года назад

      @@LucidProgramming Thanks for the great set of videos. My go to playlists.
      On this one - a bit confused as to how the recursion is getting back to the right child. In the example, after reaching 4, the left child is none. So the recursive function should not enter the loop at all, so how is reading the right child (5)? I get the code intuitively, but am stuck when trying to create the stack line by line to understand the recursion well.

    • @LucidProgramming
      @LucidProgramming  3 года назад +1

      @@ajrvasu I think what might be insightful is to print out the elements as you make the recursive calls. That might make it a bit clearer as to what is happening. Hope that helps!

    • @ajrvasu
      @ajrvasu 3 года назад +1

      @@LucidProgramming Thanks for the suggestion.

    • @LucidProgramming
      @LucidProgramming  3 года назад

      @@ajrvasu No problem, cheers!

  • @minaliaggarwal
    @minaliaggarwal 5 лет назад +3

    Hi- I think the code for post-order traversal might be incorrect.
    Is it supposed to output: [4, 5, 2, 6, 7, 3, 1]? Saw a similar tree in this article with this as the output: www.geeksforgeeks.org/iterative-postorder-traversal-using-stack/

    • @LucidProgramming
      @LucidProgramming  5 лет назад

      Hi Minali. You are absolutely correct. I checked to make sure the other traversals are correct, and they appear to be. As you say though, there seems to be something incorrect about the post-order traversal. I will be updating the code and also adding a note to the video to ensure others are aware of this. Thank you very much for pointing out my error, I sincerely appreciate this as it improves the quality of the content on this channel. Cheers, and thank you again.

    • @minaliaggarwal
      @minaliaggarwal 5 лет назад

      No problem! Thanks for fixing it!

    • @LucidProgramming
      @LucidProgramming  5 лет назад

      Ah actually, I believe my issue here was I was calling the "inorder" function inside of the "postorder" function. Another helpful commenter pointed this out and I have since fixed the code. D'oh! :) Thanks again for letting me know, and thanks for your help!

  • @user-jc3gx2mj9u
    @user-jc3gx2mj9u Год назад +1

    Thank you sir!

    • @LucidProgramming
      @LucidProgramming  Год назад +1

      You're very welcome. Thank you for watching!

    • @user-jc3gx2mj9u
      @user-jc3gx2mj9u Год назад +1

      @@LucidProgramming I watched many videos on this subject, yours is spot on!
      You're a great teacher, thanks again!

    • @LucidProgramming
      @LucidProgramming  Год назад +1

      @@user-jc3gx2mj9u thank you for the kind words!

  • @NoorAli-uh4uq
    @NoorAli-uh4uq 5 лет назад

    Thanks for thsi amazing content but I have one question in the print function where is tree coming from?
    for example line 3 in the code below, there is no varible called tree so I don't understand why you are using? and instead can I use self.root.
    Thanks
    1.def print_tree(self, traversal_type):
    2.if traversal_type == "pre_order":
    3. return self.pre_order(tree.root, " ")
    4.elif traversal_type == "in_order":
    5. return self.in_order(tree.root, " ")
    6.elif traversal_type == "post_order":
    7.return self.post_order(tree.root, " ")
    else:
    print("Traversal" + str(traversal_type), " is not supported")
    return False

    • @LucidProgramming
      @LucidProgramming  5 лет назад

      Hi Noor. If you print the type of tree, this might cast light as to what this is referring to. For instance: print(type(tree)). Using tree.root or self.root have the same effect.

  • @user-jd3hb4vd2z
    @user-jd3hb4vd2z 2 года назад

    Thank you 🙏🙏🙏

  • @rhythmsaparia8788
    @rhythmsaparia8788 4 года назад +1

    I have a doubt, after a while adding nodes by writing tree.root.left.right.left bla bla becomes a cumbersome process, if you could suggest a better and easier way to add nodes than it would be a great help, thanks.

  • @bronik7
    @bronik7 2 года назад

    (17:57) Why in preorder_print (line 4) you passing tree.root? why not self.root? to me it's not clear how Class knows about it's instance?
    Can you please explain?
    Thank you

  • @kshitijtewari2025
    @kshitijtewari2025 4 года назад +13

    Thanks Sir, what is difference b/w class Node(object): and class Node:

    • @LucidProgramming
      @LucidProgramming  4 года назад +5

      No difference at all!

    • @amithpandit4043
      @amithpandit4043 4 года назад +2

      That's right. No difference. According to the link below: in Python 2.7 and older, you need to add the object inside parenthesis. In Python 3 and above, it doesn't make a difference.
      introtopython.org/classes.html

    • @abhinavreddy5350
      @abhinavreddy5350 4 года назад

      @@amithpandit4043 kk tq :)

  • @nivi8319
    @nivi8319 3 года назад

    @19:30 i don't know if my doubt sounds silly but I want to know how it is moved upward when there is no left or right subtree
    I didn't get that
    please can you explain??
    and thank you for this amazing video : )

    • @LucidProgramming
      @LucidProgramming  3 года назад +1

      Thanks, Nivi. I think you might benefit from checking out my recursion playlist as that might clear this up. Hope that helps!

    • @nivi8319
      @nivi8319 3 года назад +1

      @@LucidProgramming ohh thanks a lot , I'll check that

    • @LucidProgramming
      @LucidProgramming  3 года назад

      @@nivi8319 Cheers, let me know if you have questions!

  • @kl-je3up
    @kl-je3up Год назад +1

    explains it way better than my ds&a textbook lol

    • @LucidProgramming
      @LucidProgramming  Год назад

      Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!

  • @raheemwilliams7998
    @raheemwilliams7998 3 года назад

    how are you able to access attributes from another class without creating an object for it or even using inheritance? plz explain

    • @LucidProgramming
      @LucidProgramming  3 года назад

      I think you might need to look into object oriented design on your own. I'm not going to give you a lecture on OOP principles in a RUclips comment.

  • @supamdeepbains5172
    @supamdeepbains5172 5 лет назад +1

    best explanation on youtube!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    • @LucidProgramming
      @LucidProgramming  5 лет назад

      Haha, cheers Spamdeep, I really appreciate that :). Happy coding, and thanks for the kind comment!

    • @ravitanwar9537
      @ravitanwar9537 5 лет назад

      @@LucidProgramming actually the name is supamdeep not spamdeep

    • @LucidProgramming
      @LucidProgramming  5 лет назад

      @@ravitanwar9537 Whoops. Must have been my autocorrect? Sorry about that. Thanks for catching, Ravi.

  • @karinah6762
    @karinah6762 3 года назад

    Hi, why when you define the node class or binary class it inherits from object class?

    • @LucidProgramming
      @LucidProgramming  3 года назад

      This is the way in which you define a class in Python.

  • @kionlingg
    @kionlingg 4 года назад

    For the output on 19:38 I received an output "Traversal type preorder is not supported." Is that the correct output? Am I missing something?

    • @LucidProgramming
      @LucidProgramming  4 года назад

      You should check your code against mine on GitHub.

  • @ritviks.8587
    @ritviks.8587 4 года назад

    Can you tell me what does "start.value" mean in the traversal methods? I am not that great in understanding classes. Thanks for the great video btw.

    • @LucidProgramming
      @LucidProgramming  4 года назад

      We are accessing the attribute "value" associated to the node object "start".

    • @ritviks.8587
      @ritviks.8587 4 года назад

      @@LucidProgramming Thanks a lot!

    • @LucidProgramming
      @LucidProgramming  4 года назад

      @@ritviks.8587 Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. I hope to be putting out more similar videos soon!

  • @shivanshtiwari4900
    @shivanshtiwari4900 4 года назад

    Sir from where you draw trees in PPT.
    Can you suggest any app

    • @LucidProgramming
      @LucidProgramming  4 года назад +1

      Shapes? If you can draw a circle and draw line, you can draw a tree.

  • @VarunKumar-pz5si
    @VarunKumar-pz5si 3 года назад +1

    Can you explain the recursion in pre-order traversal?

    • @LucidProgramming
      @LucidProgramming  3 года назад +1

      Got a whole playlist on recursion you can check out!

  • @tkannab1
    @tkannab1 5 лет назад +2

    Thank you SO MUCH for the great tutorial, one of the best I've seen so far! I just found your channel and it is a real treasure! please keep up the great work!
    I'm new to python :) so please forgive my silly question! in the helper function print_tree, you passed tree.root to the 3 printing functions, maybe I'm missing something here but shouldn't it be self.root instead of tree.root?
    Thank you again!

    • @LucidProgramming
      @LucidProgramming  5 лет назад +2

      Hi Toufi. First of all, welcome to the world of Python! :) The world of programming and computer science is a great one, and I hope you find it to be as pleasant as I do. Thanks very much for your kind words, I do indeed intend to continue producing more, and, hopefully progressively better content.
      Thanks for your question. Indeed, that's a good one, and without knowing some of the subtler points of Python, this can seem a bit confusing. The parameter "self" is a convention used in Python to denote a class variable. We created a BST class, and any time we want to refer to a specific variable in that class, we can make use of the self keyword to do so.
      Now, in the bottom part of the program, we create an instance of a BST object based on our class. The "self" variable is not accessible to us on this level as it is only accessible inside the class. For more information about these sorts of things, I'd recommend reading up a bit on Python classes. I think that should hopefully clear up any confusion.
      Thanks again for the question and the kind words. Cheers!

    • @ilanaizelman3993
      @ilanaizelman3993 2 года назад

      @@LucidProgramming Yes but if we didn't instantiate BinaryTree class as 'tree' then it won't work. So 'self' should be the right approach here.

  • @arkster00
    @arkster00 6 лет назад +5

    In the postorder_print function, I think you are calling the inorder_print function for the left and right nodes erroneously (copy/paste error).

    • @LucidProgramming
      @LucidProgramming  6 лет назад +1

      Yep, you are indeed correct. Looks like I too hastily copied and pasted from the previous traversal. I'll make sure to update my code on Github to reflect the correct traversal algorithm. Nice catch, and thanks for watching!

    • @arkster00
      @arkster00 6 лет назад +1

      Not a problem. Thank you for posting. All of this is pretty helpful and makes things more clear for the rest of us.

    • @LucidProgramming
      @LucidProgramming  6 лет назад

      Any time Ahmer, happy to hear that these videos are helpful to others. Cheers and have a nice day!

    • @theguildedcage
      @theguildedcage 5 лет назад

      Hello, I looked for traversals on your Github. Couldnt find it. Could you post a link or code correction? Thanks for taking the time to share you knowledge with the masses!

  • @samkruse6242
    @samkruse6242 5 лет назад +1

    This is gold

    • @LucidProgramming
      @LucidProgramming  5 лет назад

      Thanks, Sam! I'm glad that this video was useful to you. Thanks for the comment and for watching! Cheers.

  • @redpred3502
    @redpred3502 3 года назад

    For the functions being returned in the print_tree method, what difference would it make if self.root was used as arguments instead of tree.root? Doesn't tree.root limit the class to just that object?

    • @LucidProgramming
      @LucidProgramming  3 года назад

      Have you tried doing that?

    • @redpred3502
      @redpred3502 3 года назад

      @@LucidProgramming I did and now it works with different named trees.

    • @LucidProgramming
      @LucidProgramming  3 года назад

      @@redpred3502 Right, because "self" and "tree" both refer to an instance of the Tree class.

    • @ZhuYiting612
      @ZhuYiting612 3 года назад

      @@LucidProgramming and by using "self.root" can make the function works for an instance with any name other than the name "tree", right? thanks

    • @LucidProgramming
      @LucidProgramming  3 года назад

      @@ZhuYiting612 So long as you're referring to the object created in the class.

  • @gunabalang7034
    @gunabalang7034 3 года назад +1

    crystal clear

    • @LucidProgramming
      @LucidProgramming  3 года назад

      Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!

  • @natnaelberhane3141
    @natnaelberhane3141 Год назад

    If I'm not mistaken, depth of root node is 0. Root node is at level 0, not 1 :)

  • @gokusaiyan1128
    @gokusaiyan1128 2 года назад +1

    What are your vim settings/plugins? I like it

    • @LucidProgramming
      @LucidProgramming  2 года назад +1

      Good question! Much of my configuration is covered here: ruclips.net/video/vlb3qUiS2ZY/видео.html

  • @vitaliano01
    @vitaliano01 3 года назад +1

    Thank you.

    • @LucidProgramming
      @LucidProgramming  3 года назад

      Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!

  • @NoorAli-uh4uq
    @NoorAli-uh4uq 5 лет назад +2

    Amazing content but one question, why I thought in Binary trees the left_child should be less than the root, in that case if the root is 1 then the left_child cannot be 2. May be I am wrong but I appreciate if clarify that, thanks again for the amazing content.

    • @LucidProgramming
      @LucidProgramming  5 лет назад +1

      Thanks Noor. Regarding your comment, you're thinking of binary search trees. I have a whole playlist on them as well that you might enjoy. Cheers!

    • @NoorAli-uh4uq
      @NoorAli-uh4uq 5 лет назад

      Thanks for reply, I am checking your page but cannot see the Binary Search Tree vidoes, I have seen Data structures which consists of 40 video and the last 7 deals with Trees, I am not sure if they are contained there. Thanks.

    • @LucidProgramming
      @LucidProgramming  5 лет назад +1

      Hi Noor. There is a BST playlist. You can find it here: bit.ly/lp_bst. Cheers!

    • @NoorAli-uh4uq
      @NoorAli-uh4uq 5 лет назад

      Thanks @@LucidProgramming

    • @LucidProgramming
      @LucidProgramming  5 лет назад

      @@NoorAli-uh4uq No problem! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing! I really appreciate the support. I hope that the content I provide there will enhance the videos on my RUclips page.
      bit.ly/lp_email

  • @Magmatic91
    @Magmatic91 2 года назад

    Great stuff. I've been enjoying these videos so far. I'm a bit struggling to understand how recursion works in preorder_print. What's exactly happening when we hit a node with no left child, how the function is able to revert back to the previous node. I can't understand this part, can you please help me with that? Thanks.

    • @LucidProgramming
      @LucidProgramming  2 года назад +1

      I have a playlist on recursion that might be worth a look if that part if holding you up. Cheers!

    • @haciiiiiiii
      @haciiiiiiii 2 года назад +1

      I see several people struggle to understand how the recursive function moves up to previous node. In simple terms, we call the preorder_print function with the root (it is now stored in stack) which recursively calls the function with root.left, gets stored in stack (which also in return calls the function again with its left node, gets stored in stack) and all these functions are dumped from the stack when they return something. (when you call the recursive function with the root, it firsts call the function with its left node and when this returned something, the function moves to the next line, it prints its value and then calls the function with its right.

    • @Magmatic91
      @Magmatic91 2 года назад

      @@haciiiiiiii Thanks, very helpful !

  • @ravitanwar9537
    @ravitanwar9537 5 лет назад

    inorder traversal result is supposed to be in sorted order . any ideas ?

    • @LucidProgramming
      @LucidProgramming  5 лет назад

      Hi Ravi. Not necessarily for any binary tree, no. If you applied an inorder traversal to a binary search tree, then yes, the nodes would appear in order based on the ordering principle of the binary search tree. This is not necessarily true for a binary tree as it does not have this ordering principle imposed on it. Hope that makes sense, and thanks for your question.

    • @LucidProgramming
      @LucidProgramming  5 лет назад +1

      I should also say that "in order" is with respect to how one reads the nodes of a binary tree when reading the nodes from left to right. Note that, of course if the data values of the nodes are not likewise ordered in such a fashion, an in order traversal will not yield an output in sequential order. Hope that clarifies things further. Cheers.

    • @ravitanwar9537
      @ravitanwar9537 5 лет назад

      yeah you are right . that was binary search tree i was talking about .thanks for such an informative reply.
      can you share your email id ?

    • @LucidProgramming
      @LucidProgramming  5 лет назад

      Great, glad that cleared things up. You can find my contact in the "about" section of my channel. However, unless you intend to reach out regarding a tutoring or consulting session, I would encourage you to keep communication in the comment section so as to help other viewers who may be encountering similar problems or who have similar questions. Cheers!

  • @drcylon
    @drcylon 2 года назад

    I think there is a little error in the "print_tree()" function, it shouldn't be "tree.root" it should be "self.root" ! Plus the "postorder" error pointed out in some comments below!
    Still, it is a great effort. Thanks.

  • @cdemr
    @cdemr Год назад +1

    I am on Pycharm and I am a beginner. I do not understand what you're doing at 18:15.
    I can force-erase the consol but I can't write inside it.

  • @yoloprk9761
    @yoloprk9761 5 лет назад

    Why you passing object with every class?is it mandatory in python3.x

    • @LucidProgramming
      @LucidProgramming  5 лет назад

      No, it's not mandatory, but it makes it explicit if you have multiple classes in the future and want to use inheritance between them. You can take it out, and it won't make any difference. I just find the explicit nature to be a bit more clear, but you can decide in your own code whether that is the case or not.

  • @ayushisingh6638
    @ayushisingh6638 3 года назад

    I didn't get that in Inorder traversal like how from node A it's Going back to Node B?

    • @LucidProgramming
      @LucidProgramming  3 года назад

      You might want to check out my playlist on recursion if this part is confusing to you.

  • @neildutoit5177
    @neildutoit5177 2 года назад

    checking for None using a bool cast is also an anti-pattern. Use "if start is not None" instead.

  • @someshsangwan3768
    @someshsangwan3768 2 года назад +1

    Thnq sir I am facing a TypeError: Binary tree takes no argument .
    Tell me about this

    • @LucidProgramming
      @LucidProgramming  2 года назад

      You might want to check your code against my GitHub code.