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

แชร์
ฝัง

ความคิดเห็น • 61

  • @robbie5416
    @robbie5416 2 ปีที่แล้ว +44

    The video we needed but didn't deserve. Thank you! Never thought a simple video like this would answer so many questions I had.

  • @jarjarbinks8954
    @jarjarbinks8954 2 ปีที่แล้ว +31

    this was soooo well done. Thank you a lot. I know Im not the only person who desperately needed this

    • @machinelearningandartifici9819
      @machinelearningandartifici9819 ปีที่แล้ว +1

      yes, very well made. really love this concrete dry runs. most cs teachers don't do this in class because of the amount of hard-work it takes to draw this out on a whiteboard...
      but as a student its so necessary to see this

  • @HussainAbdi_
    @HussainAbdi_ 11 หลายเดือนก่อน +3

    Thank you! Preparing for my Meta interview and this video is exactly what I needed to help visualise things so I could better understand converting a BST into a DLL. As simple as the code is, being able to visualize recursion as a stack the way you did will really help internalize what's going on for harder problems. Subscribed - I see you're still making videos! Keep creating!!!

  • @MyBinaryLife
    @MyBinaryLife 4 หลายเดือนก่อน

    ive been trying to learn trees for like a year and this is the best content I've found so far, thank you for putting this out

  • @for461
    @for461 3 หลายเดือนก่อน

    OMG Sir you are Super. This kind of teaching should be there in every university with visualization. Thanks a lot. Many thanks Sir !!!!! Amazing Explanation.No one could explain like you. You have a lot of Patience Sir !!!!!

  • @santiagobenitezperez5240
    @santiagobenitezperez5240 2 ปีที่แล้ว +3

    this visualization was beyond awesome.. thank you!!

  • @tosin23
    @tosin23 2 ปีที่แล้ว +1

    this is the best explanation video i’ve seen on this topic, thank you!!

  • @MrInboxer
    @MrInboxer 2 ปีที่แล้ว +1

    This video deserves more views and likes!!

  • @ImmediatelyLeaveYT
    @ImmediatelyLeaveYT 3 หลายเดือนก่อน +1

    top notch explanation and content sir

  • @tanishq2766
    @tanishq2766 ปีที่แล้ว

    Keep making videos plewaseeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee, this was sooo good, the visualisation that we needed so damn much! Thankssssssss

  • @tbzz99
    @tbzz99 ปีที่แล้ว +3

    What a great video, really really awesome explanation!

  • @neuralworknet
    @neuralworknet ปีที่แล้ว +1

    Perfect explaination!

  • @ojithmagamage1809
    @ojithmagamage1809 4 หลายเดือนก่อน

    Thanks for this precise explanation!

  • @cycla
    @cycla 2 ปีที่แล้ว

    best visualization of binary trees ever, why aren't you getting more views

  • @carefree_ladka
    @carefree_ladka ปีที่แล้ว

    Thanks a lot . I now understand how recursion works with trees

  • @ScraperCross
    @ScraperCross ปีที่แล้ว

    Incredibly helpful! Thank you so much!

  • @kailashlakshmikanth7386
    @kailashlakshmikanth7386 3 ปีที่แล้ว +1

    great explanation!! :) finally understood tree traversal using recursion

  • @eslamahmed-zr8rl
    @eslamahmed-zr8rl ปีที่แล้ว

    This video helped me a lot understanding recursion on trees
    thanks a lot

  • @skylersimpson4844
    @skylersimpson4844 ปีที่แล้ว +1

    bro is the goat

  • @asmallapple1509
    @asmallapple1509 ปีที่แล้ว +1

    Goated video

  • @shaziakaleem1895
    @shaziakaleem1895 10 หลายเดือนก่อน

    Great explanation, very helpful. Thank you

  • @sekirandahamza1260
    @sekirandahamza1260 2 ปีที่แล้ว

    Awesome explanation. You are the best.🙌

  • @DP-md4jf
    @DP-md4jf 10 หลายเดือนก่อน

    Wow amazing video thank u sir. Liked and subscribed

  • @gvlog1607
    @gvlog1607 2 ปีที่แล้ว +1

    God bless you.

  • @raghusagar-r3c
    @raghusagar-r3c ปีที่แล้ว

    Thank you for the video.

  • @abhitejamandava1619
    @abhitejamandava1619 3 ปีที่แล้ว

    Awesome explanation mate

  • @TJ_12138
    @TJ_12138 2 ปีที่แล้ว +1

    Very useful!

  • @saliheenafridi9116
    @saliheenafridi9116 10 หลายเดือนก่อน

    Thank you very much. Yo got a subscriber

  • @yunanistan2364
    @yunanistan2364 ปีที่แล้ว

    Exactly what I search for.

  • @deepamanne
    @deepamanne 3 หลายเดือนก่อน

    well done!

  • @elsayedmohamed451
    @elsayedmohamed451 9 หลายเดือนก่อน

    many thanks

  • @lin99nn
    @lin99nn 2 ปีที่แล้ว

    thanks for sharing, it's very helpful

  • @aadityaprakash139
    @aadityaprakash139 2 ปีที่แล้ว

    great visuals

  • @brettclifford2723
    @brettclifford2723 2 ปีที่แล้ว

    Omg i love you for this video

  • @gokulr3482
    @gokulr3482 ปีที่แล้ว

    simple but great

  • @sameerroshan9542
    @sameerroshan9542 ปีที่แล้ว

    what does root mean here int he function definition and base case?

  • @carolineli7948
    @carolineli7948 ปีที่แล้ว

    thank you!!

  • @yashwanth73337
    @yashwanth73337 ปีที่แล้ว

    How does the computer realise that a node has been processed completely i.e left and right child is none...so the current node has to be removed from the stack?
    How?
    This is what's been bugging me...
    How does it realise "it's time remove the node from stack"?

    • @ポヤポヤ
      @ポヤポヤ ปีที่แล้ว

      the node from stack will be removed once it reached the 'base case', the base case stops the recursion (you see the code says return). then it will proceed to the next stack.

    • @kostiantynshyshkovskyi630
      @kostiantynshyshkovskyi630 11 หลายเดือนก่อน +1

      Perhaps it will be helpful if I try to explain how I understood it. The values are added to the stack(last in first out) and it pops from the stack when we reach the base case. As soon as we face the NULL method returns the value to the caller and then the method will be called with the previous input. For instance, if we have node 1 and there’s no left nor right node it means we have input 1 and try to reach the left child it’s NULL we return the default value and take a step back to the node with 1 value print the value, and we try to reach the right child and it returns the default value because there no right child as well and we again take a step back to the node with the 1 value but we already have the outcome we return it to the caller(the previous one who called the method with this node where the value is 1)

  • @kalahari8295
    @kalahari8295 2 ปีที่แล้ว

    Omg thank you 😭❤️🔥

  • @encapsule2220
    @encapsule2220 ปีที่แล้ว +1

    i still dont get it.

  • @bananaboydan3642
    @bananaboydan3642 ปีที่แล้ว

    What prevents the code from going back to 1 when inorder(root.left) is called

    • @isaicruz7867
      @isaicruz7867 ปีที่แล้ว +1

      Think of each call of the inorder functions (inorder(root.left) & inorder(root.right)) causing a “freeze” of the current “instance” that you’re working through. So to your question, when we first visit root 2 (which was executed by calling inorder(root) where root is the value of 2, we skip the base case (of course) and execute inorder(root.left) and we know to replace root.left with the value of 1 since that’s root 2’s left child. At this point, think of the current “instance” that we’re working through (the execution of inorder(root) where root is the value of 2) as now being frozen in time (and for visualization help, think of the white arrow as staying stuck on pointing at the line inorder(root.left)). Since we just executed a recursive call (inorder(root.left)) with root.left being the value of 1, we go back to the top of the function to execute this (inorder(root)) where root is the value of 1. Jumping ahead a few steps since we don’t care about 1 as the root since they have no children, we eventually end up finishing working on inorder(root) where root is the value of 1. So we go back to root 2 where we left off with it “frozen” and the frozen arrow pointing at inorder(root.left). We can now “unfreeze” the arrow since everything we had to do inside of that inorder(root.left) call where root is 1, is now complete. We can now move the arrow down to the next line and continue with the last two lines. Remember, since you specifically asked about root 1, this same “freezing” technique has already occurred to other root values, so you would be “unfreezing” these instances as well when you eventually get done with their left children. Feel free to ask for clarification on anything

  • @venkatraghavansriperambhud1871
    @venkatraghavansriperambhud1871 ปีที่แล้ว +1

    this got me to the closet understanding. Questions how did the tree go from 1 -> 2? Thank you.

    • @carefree_ladka
      @carefree_ladka ปีที่แล้ว

      When the node 1 gets traversed (including its left and right subtree) , it gets popped off the stack and the control goes to as 1 is a left subtree of 2

  • @juyeon_kim
    @juyeon_kim 2 ปีที่แล้ว

    thank you

  • @sash11g
    @sash11g หลายเดือนก่อน

    graet content

  • @arindam6130
    @arindam6130 2 ปีที่แล้ว

    this was helpful, tysm

  • @semih-ze9uo
    @semih-ze9uo 2 ปีที่แล้ว

    thanks a millions

  • @blockchainbaddie
    @blockchainbaddie 5 หลายเดือนก่อน +1

    holy shit

  • @ohsopaid1614
    @ohsopaid1614 ปีที่แล้ว

    goat

  • @srishtijha3
    @srishtijha3 2 ปีที่แล้ว

    So helpful

  • @DoubleChase
    @DoubleChase ปีที่แล้ว

    useful

  • @shashicsnitjsr
    @shashicsnitjsr 3 ปีที่แล้ว

    How do you create animation ? Do you use powerpoint or some other software?

    • @ygongcode
      @ygongcode  3 ปีที่แล้ว +3

      I used github.com/3b1b/manim and coded all the animations as well as my own data structures for the animations.

    • @coffeepwrdcomputers
      @coffeepwrdcomputers 3 ปีที่แล้ว +2

      @@ygongcode Do you happen to have the source code for the animations available somewhere? I only ask because I just started messing around with manim and example code for making data structure visualizations are few and far between.

  • @NavJaswal
    @NavJaswal หลายเดือนก่อน

    Binary tree questions on leetcode had me cooked fr. NOT ANYMORE.

  • @AmanSingh-vy5tk
    @AmanSingh-vy5tk หลายเดือนก่อน

    The ordin porject (i made it till here)

  • @anurag-sachan
    @anurag-sachan 2 ปีที่แล้ว

    🫡🚀 thanks alot bro.