Pre-order Traversal Algorithm | Tree Traversal | Visualization, Code, Example

Поділитися
Вставка
  • Опубліковано 12 гру 2020
  • A visualization of how the pre-order tree traversal works.
    If you like this content, please like and subscribe, so I can make more.
    Follow me on my socials and blogs, which has tons of educational resources.
    Linkedin: / ygongcs
    Tech Blog: ygongdev.github.io/blog/
    Personal Finance Resources: www.smartfinance.fyi/
    Animations were custom made using 3blue1brown's animation engine.
    github.com/3b1b/manim
  • Наука та технологія

КОМЕНТАРІ • 33

  • @user-rt1qt5vl3j
    @user-rt1qt5vl3j 3 місяці тому +3

    IIt takes me so long to find someone who can easily explain the stack frame with recursion. This is really easy to understand! Thanks a lot.

  • @Mr2Am3
    @Mr2Am3 2 роки тому +6

    Couldnt understand what my lecturers were teaching till I came into this video, which was explained in terms of call-stack, where my other teachers failed to recognise. Thank you for saving my grades!

  • @ragnarokjunekoesco7246
    @ragnarokjunekoesco7246 Рік тому +1

    By far clearest explaination on binary preorder recursion traversal, thank you!

  • @nwokolobueze7291
    @nwokolobueze7291 Рік тому

    Great explanation, the best I have seen so far. I am definitely liking and subscribing.

  • @byte_easel
    @byte_easel 10 місяців тому +3

    I just wanted to say thank you so much. I know how much this time this must have taken writing the visualization animations but your work doesn't go unappreciated. You going over how it looks like at each frame in the call stack was really essential. Also, I really appreciate the visualization of the print output and where we are in the bst. Thank you so much ygong!!

  • @MeisterMattz
    @MeisterMattz 3 місяці тому

    Great explanation! Your animations make tree traversals so much clearer. Thanks a lot

  • @freeBirbBirb
    @freeBirbBirb 5 місяців тому +1

    best video for understanding traversal BST, thank yo so much

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

    Thank you so much, this really helps!

  • @Srinivasssssss
    @Srinivasssssss 6 місяців тому

    This animation really helped a lot...

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

    Wow this wouldve been so helpful back in college. This stuff was a nightmare to me back then.
    And now a few years later, I'm needing to rebrush up on these skills to stay marketable for interviews... Thanks

  • @harishks308
    @harishks308 3 місяці тому

    Great explanation..very useful 🙏😍

  • @user-mt7yl7zp4x
    @user-mt7yl7zp4x Рік тому +1

    simple explanation thank you so much man

  • @AkashRoy-do2dg
    @AkashRoy-do2dg 2 роки тому

    you are a lifesaver!

  • @alperendilaver.
    @alperendilaver. Рік тому

    excellent explanation thank you

  • @kristuze1
    @kristuze1 Рік тому

    omg, it finally clicked to me!!!!!!!!!!! Thank you sooo much

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

    Such a good video....

  • @expansivegymnast1020
    @expansivegymnast1020 Рік тому +1

    You dropped this fam 👑

  • @htooaung6248
    @htooaung6248 4 місяці тому

    THANK U BROTHER.

  • @ayanaxhye
    @ayanaxhye Рік тому

    awesome explanation sir

  • @longjieguan7275
    @longjieguan7275 Рік тому

    very helpful

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

    best video animation

  • @SuperBhavanishankar
    @SuperBhavanishankar 6 місяців тому

    Thank you

  • @chethanvenkataramaiah6940
    @chethanvenkataramaiah6940 11 місяців тому

    This is seriously the best visualization explanation so far , but how does it pop things out of the stack by remembering? Like when the control hits the leaf node 1 , the left node is null , it returns null, I really dont understand how it remembers the previous execuition of the statement preorder(root.left) was null and proceed to the next statement

  • @ahmetokur6983
    @ahmetokur6983 Рік тому

    that was by far the best video , thank you so much for this great explanation. The only thing I don't understand is that after we are done leftmost node(1), we pop the preorder(1) from call stack and go to preorder(2) and what stops program to go again to left child of node(2) here. And instead of going to node1 again it goes back to top. i dont understad what prevent going to node1 again in the preorder2 function in the calla stack.

    • @ygongcode
      @ygongcode  Рік тому

      At 2:36, notice the yellow code arrow. We entered preorder(1) via preorder(2)'s "preorder(root.left)". So when we are done with preorder(1), we have exited out of preorder(2)'s "preorder(root.left)", so we would move onto preorder(2)'s "preorder(root.right)", so we'll never visit node(1) ever again b/c we'll never execute "preorder(root.left)" in preorder(2) past this point.

    • @SuperBhavanishankar
      @SuperBhavanishankar 6 місяців тому

      🔥🔥😍😍🥰🥰💖💖🙏🏽🙏🏽@@ygongcode

  • @sheikhraisulislam4483
    @sheikhraisulislam4483 Рік тому

    why just 490 subscription... so good

  • @practicalcoder4372
    @practicalcoder4372 11 місяців тому

    can you explain why this preorder(root.right) is automatically called for the parent node even if the pointer is at the child

  • @pal2004
    @pal2004 Місяць тому

    I dont understand why we are making a recursive call to the Root. I mean the First Step is to process the Root, thats Not recurisve ,so why the 5 gets in to the Stack?

  • @user-to9zj3jd2k
    @user-to9zj3jd2k 2 роки тому

    good video, Can you do this for a post-order video.

    • @ygongcode
      @ygongcode  2 роки тому +1

      Yes, it is here ua-cam.com/video/4Xo-GtBiQN0/v-deo.html