Morris Inorder Tree Traversal

Поделиться
HTML-код
  • Опубликовано: 29 сен 2024

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

  • @sidharthbihary2475
    @sidharthbihary2475 5 лет назад +216

    came here when I didn't get the geeksforgeeks explanation. you have explained it lucidly.

  • @alexnice2221
    @alexnice2221 5 лет назад +283

    Good luck to everyone working hard to be at good tech companies. Thank you for the explanation.

  • @mierta7751
    @mierta7751 2 года назад +6

    Thank you Tushar! Your video is always a guarantee of crystal clarity. Kudos!

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

    Thanks for your explanation! I was confused about Morris Traversal, but you video make me clear now.

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

    thanks, sir really nice explanation....!

  • @karthikeyy
    @karthikeyy 8 лет назад

    Great Explanation sirji...

  • @Virtualexist
    @Virtualexist Год назад +8

    Best explanation ever. Better than pepcoding, better than Striver.

  • @jubjubfriend64
    @jubjubfriend64 4 года назад +28

    Man I spent like 2 hours trying to understand the code, but visually seeing it step by step made it finally make sense, thanks!

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

    I have skipped Morris Traversal for the past 7 years because I never understood it. Turns out, I only had to watch this 10 minute clip. Thanks a ton man.

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

    Great content but this dude is the personification of the universal example of "how NOT to talk while talking to the audience"

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

    Looking For Same Logic Small Code ?
    while(root){
    if(!root->left){
    coutright)suck = suck->right;
    suck->right = root;
    suck = root->left;
    root->left = NULL;
    root = suck;
    }
    }
    HAPPY LEARNING :)
    And Yes I wanted To Name "suck" ...

  • @gooomarco
    @gooomarco 5 месяцев назад +2

    Thank you! This was the best explanation I found. Instead of going straight into algorithm, Tushar explained the thought behind it. Great job.

  • @NihalSingh-ld2en
    @NihalSingh-ld2en 2 года назад +1

    Don't you spit whenever you say "t"?

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

    Almost I gave my 2 hours to understand this algorithms on others channel but when I watched this video I got it. Great explanation.

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

    Out of all Morris algorithm explanations out there, yours is so much better. Thank you!

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

    Patience, friends. Bit by bit.

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

    Nice explanation sir...

  • @SAURAVVISHNUGITTE
    @SAURAVVISHNUGITTE 3 месяца назад

    there is a problem at 6:45 , after visiting -1 , we got to 2 , then we begin finding predecessor of 2 ,
    Alas , finding predecessor of 2 means going right most in left sub-tree of 2 ,
    here left subtree is -1 , then lets find predecessor ,-1 -> right = 2 , then 2-> right = 5 , 5-> right = 6 , 6-> right = 8 , 8 ->right = 10 , we are moving in totally different direction ....now .
    Actually this must stop when predecessor is found , but for predecessor , we keep moving right ?
    Edit: Now I saw the final code , while finding predecessor , you solved the problem by doing , predecessor-> right = current , then break .

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

    thank you for the video!! but at 7:27 current = current.right, but you were pointing to the wrong place on the white board.

  • @uploadheartseexy
    @uploadheartseexy 8 лет назад +9

    Tushar, Great effort on the explanation. But, it seems your algorithm on the board was incomplete (like when the predecessor->right hits the current item itself, then it should stop). Although, you do talk about it while you showcased the code. Also, When you said current becomes current-> right @7:27 , you should actually be pointing at the last else section of your algorithm.

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

      exactly, i was also confused by that pointing...

  • @JIHYELEE-h2m
    @JIHYELEE-h2m 2 месяца назад

    Wow the intro is so good!! now I understand why thread(link) is needed! bc we have to come back root, without stack or recursion! wow Thanks my teacher!!!

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

    People who are looking for Morris POSTORDER Traversal algorithm and working solution, please visit www.thealgorists.com/Algo/Tree/MorrisPostorder

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

    There's a LOT of bad articles poorly explaining this, and I gave up after checking a few. This cleared it up pretty quickly. I do wish in his first pass he hadnt abstracted findPredecessor() into some invisible function.

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

    Thank You

  • @AKProductionsTelugu
    @AKProductionsTelugu 2 месяца назад

    0:01 turn on subtitles and see Tushar's name 😂😂

  • @BlueBunnyGamer
    @BlueBunnyGamer 6 лет назад +9

    I've watched this like 10 times xD

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

    public List inorderTraversal(TreeNode root) {
    List res = new ArrayList();
    TreeNode curr = root;
    while(curr!=null){
    if(curr.left == null){
    res.add(curr.val);
    curr = curr.right;
    }
    else{
    TreeNode pred = findPred(curr);
    //link back if right null
    if(pred.right == null){
    pred.right = curr;
    curr = curr.left;
    }
    // if right not null, we have visited, unlink
    else{
    pred.right = null;
    res.add(curr.val);
    curr = curr.right;
    }
    }
    }
    return res;
    }
    TreeNode findPred(TreeNode node){
    TreeNode current = node;
    node = node.left;
    while(node.right != null && node.right != current) node = node.right;
    return node;
    }

  • @himanshusharma7417
    @himanshusharma7417 8 лет назад +2

    Hi Tushar. I want to thank you for this video. I looked at almost all sources that explain morris traversal but yours actually made everything clear in my mind. Keep making more videos like this. Thanks again.

  • @HimanshuKumar-ew8ly
    @HimanshuKumar-ew8ly Год назад +1

    thhooo

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

    The last, please like this video..damn he spoke at 3x!

  • @HaiderAli-nn3gy
    @HaiderAli-nn3gy Год назад

    Very Good Explanation Thanks

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

    Excellent explanation of Morris Algorithm !! keep up the good wrk Tushar !! I keenly follow your videos and they are immensely helpful in understanding concepts of Compute rScience.

  • @sarramarmouche8344
    @sarramarmouche8344 3 месяца назад

    Thank you great explanation

  • @ShabnamKhan-cj4zc
    @ShabnamKhan-cj4zc 7 лет назад +1

    Thanks tushar For explaining in simple manner with algorithm and code.

  • @nikhilagrawal9217
    @nikhilagrawal9217 29 дней назад

    Awesome explaination!!

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

    Why not to use threaded three in the first place?

  • @vartikapriyadarshini4511
    @vartikapriyadarshini4511 3 месяца назад

    Very good explanation!!

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

    Please use a good mic or else edit your audio too

  • @Tommy-dd5pz
    @Tommy-dd5pz 2 года назад

    why time complexity is O(n)?

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

    Clean and precise explanation !!

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

    Awesome man... Nice explanation

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

    Super good explanations!

  • @shuxuannie1470
    @shuxuannie1470 8 лет назад +2

    The best video about morris! Love your video!

  • @panchajanya1967
    @panchajanya1967 8 месяцев назад

    It’s a good explanation for those looking in to the problem already and stuck with solving it. For those looking in to the problem first time, it would help if the pace of explanation is bit slower.

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

    very clear thank you so much

  • @aaronschwartz-messing4701
    @aaronschwartz-messing4701 3 месяца назад

    Thank you! This is the most thorough video explanation on Morris Traversal that I have been able to find.

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

    Thanks for your hard work for making such nice videos!
    But it would be great if the video explains algorithm derived from concept behind it.
    What I understand, concpet is the first thing then algo comes. You explan such a way where algo comes first then explain the concept based on the algo! Thank you!

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

    Very nice explanation 🙌🙌

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

    Explanation is Awesome !

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

    Loved your explanation

  • @rup7591
    @rup7591 7 лет назад +16

    Nice thoking....
    Joking aside , nice tutorial.

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

    thanks for the explanation

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

    Can we use this to traverse inorder reversely(right->root->left) ? ig yes ...reply if not

  • @tusharsinha313
    @tusharsinha313 7 лет назад +1

    Nice explanation!

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

    Good Explanation. :)

  • @uttamnandi124
    @uttamnandi124 7 лет назад +1

    very well explained..thank you so much

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

    we need a way to come back to 5

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

    u Hv written it very small

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

    I am very thankful for your clear explanation and pronunciation!

  • @chiraglosalka6893
    @chiraglosalka6893 8 лет назад

    how is the time complexity O(n)... we are revisiting nodes in a loop many times...

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

    Excellent explanation !!

  • @sammyiboi
    @sammyiboi 6 лет назад +2

    Awesome! Thank you Tushar!! :D

  • @d123-y5i
    @d123-y5i 3 года назад

    Great explaination!

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

    Thank you very much for the clear explanation.

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

    I love this guy

  • @adityatrived.i
    @adityatrived.i 4 года назад

    Nice Explanation

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

    Finally got it ....

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

    Time complexity?

  • @karthikmadan
    @karthikmadan 5 месяцев назад

    chummi explaination

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

    his diagram is clean and clear enough to demonstrate the concept

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

    Explanation was very nice , thanks for the vid :D

  • @SachinSingh-im2qm
    @SachinSingh-im2qm 3 года назад

    Nice explanation

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

    Nice explanation

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

    Explanation is excellent , simple request is to talk at steady pace. a bit slower ...then it will be much easier to absorb :)

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

    Nice explained♥️

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

    Thanks, best video on this algorithm!

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

    Are u using recursion or stack to find inorder predecessor

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

    nice explanation

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

    The best explanation I found on youtube so far

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

    nice explanation

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

    awesome explanation Much much better than Geeks for geeks

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

    Very clear!

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

    Thank you!

  • @taotang6557
    @taotang6557 7 лет назад +1

    very clear explanation!

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

    Thank you!

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

    Best person to explain complex topics. I wonder why his channel is not very famous?

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

    A+++++ explanation. Really appreciate it!

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

    nice video!

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

    Best explanation of Morris traversal on the internet

  • @TingZhou8
    @TingZhou8 7 лет назад +1

    you rock!

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

    I think the worst case time complexity will be O(n^2). Correct me if I am wrong. Coz we will have to find inorder predecessor for all nodes. And in case of skwed tree, it will take O(n^2) time.

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

      The TC will still be 2N which is O(N) as the nodes visited at max twice.

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

    your speaking is way better than others

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

    good one!!

  • @ShubhamKumar-ur1vm
    @ShubhamKumar-ur1vm 3 года назад

    Then on Then

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

    could you please make similar videos for Morris traversal for priorder and post order traversal

  • @igniculus_
    @igniculus_ 7 лет назад

    It should be (predecessor.right != current || predecessor.right != null)
    i.e. instead of && it should be || as both conditions cannot be true at the same time ....

    • @TheRaghavboyz
      @TheRaghavboyz 7 лет назад

      that's the whole point only one needs to be true to exit the loop, if you add || (or) the loop would execute infinitely because like you mentioned both can never be true at the same time.

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

    Thank you for all your videos :)

  • @Mel-jp5vb
    @Mel-jp5vb 2 года назад

    Great walkthrough, thank you!

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

    Amazing

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

    Precise and sweet explanation. thanks :)