Please likeeee, shareeee and subscribeeeeeeee :) Also follow me at Insta: Striver_79 Aaaye hi ho, toh series bhi dekh lo ;)
@user-xi5sm3dz9q2 жыл бұрын
Bilkul.
@deepaksarvepalli23442 жыл бұрын
Just informed to my friends that video is out 😁
@PrashantSingh-ej8lz2 жыл бұрын
Hey striver please add morris postorder traversal
@priyanshkumar_iitd5 ай бұрын
Wonderful explanation bhaiya...
@uRamPlus2 жыл бұрын
Self notes: In-order Morris Traversal: 🌳 1st case: if left is null, print current node and go right 🌳 2nd case: before going left, make right most node on left subtree connected to current node, then go left 🌳 3rd case: if thread is already pointed to current node, then remove the thread
@TheElevatedGuy2 жыл бұрын
Great Job Thanks!
@CostaKazistov2 жыл бұрын
Came here for this. Thank you! ✍👍
@gandhijainamgunvantkumar67832 жыл бұрын
In each video I find your comment to take the notes :)
@AbhishekYadav-rm4hw Жыл бұрын
In 3rd case shouldn't it be Remove the thread ..and THEN PRINT NODE AND GO RIGHT??
@parthsalat Жыл бұрын
@@AbhishekYadav-rm4hw Yes, right. You can add it to 'your' notes
@sparshsharma60682 жыл бұрын
By far THE BEST explanation of Morris traversal on youtube!!! Maza aagya bhaiya🔥🔥 and Happy birthday bhaiya. Thank you for being the teacher and a senior we all wanted in our lives🎉🎉 Here's the postorder morris traversal(similar to preorder), the only changes are instead of finding the rightmost node in the left subtree, we find the leftmost node in the right subtree. Also, we need to keep adding the node values in the head so as to maintain the LRN order of postorder. public List postorderTraversal(TreeNode root) { List arr = new LinkedList(); TreeNode curr = root; while(curr != null){ if(curr.right == null){ arr.add(0,curr.val); curr = curr.left; } else{ TreeNode temp = curr.right; while(temp.left != null && temp.left != curr) temp = temp.left; if(temp.left == null){ temp.left = curr; arr.add(0,curr.val); curr = curr.right; } else{ temp.left = null; curr = curr.left; } } } return arr; }
@kannank42699 ай бұрын
can you please explain the intuition of connecting leftmost node of right subtree to cur
@iamnoob759320 күн бұрын
Just replace left with right and right with left of preorder code. Thanks
@slowedReverbJunction2 жыл бұрын
Seriously bhaiya You are man of your words You said that this will be the best explanation of Morris Traversal And you proved it Hats off to to bhaiya 💪👏👏 Thank u sooo much for this awesome content ♥️♥️
@karanveersingh55352 жыл бұрын
Bro kidda? 2nd year ki 3rd.
@akashgupta132 жыл бұрын
@@karanveersingh5535 😂
@parthsalat Жыл бұрын
@@akashgupta13 😂
@anmolkohli62992 жыл бұрын
Crystal clear explanation! Understanding it from reading articles was really difficult and you made it so simple. Thank you !🙌
@CostaKazistov2 жыл бұрын
I agree. Reading about this algorithm is one thing. Watching the explanation on KZbin makes it soooo much clearer. 🔊
@priyanshkumar_iitd5 ай бұрын
Yeah, you're right.@@CostaKazistov
@JamesHalpert85552 жыл бұрын
Beautifully explained!! I watched another lecture but was struggling to come up with morris version for other traversals,now it's crystal clear thank you!!
@sauravchandra108 ай бұрын
Every time I watch it, things become more clearer. This is the third time in 6 months.
@harshanand45012 жыл бұрын
I studied it from book but was unable to understand it. But after watching your video understood it completely. Great Explanation!
@amanbhadani88402 жыл бұрын
This is indeed the best explanation of this series, truly crystal clear.Kudos to your work for the programming community Bhaiya.
@deepanshukhanna17802 жыл бұрын
Looking at the views of this video , I think this is the reason people don't make quality stuff, today's generation is more interested in watching those hypothetical motivational videos but not interested in watching what it takes to achieve your goals. Hat's off to you. Keep making such videos. Thanks a lot.
@KunalSinghStatus2 жыл бұрын
Right sir ❤️
@vivekjaiswar68252 жыл бұрын
They are more interested in "How to get into google" type of videos.
@01_abhijeet49 Жыл бұрын
Cute
@AdityaKumar-be7hx Жыл бұрын
@@vivekjaiswar6825 True. I will also add that these are the contents of videos that actually answers the question "How to get into G?" :) By becoming truly great in solving problems
@thomasshelby678013 күн бұрын
bro it doesn't take a lot to mind one's own business. Stop taking a jibe at others. Those guys might be good at thousand things that you aren't. Better if you quit perpetuating a rat race in tech that is there already.
@abhijeetmishra38049 ай бұрын
In starting i was like this video need improvement but after a certain time it was STRIVER show and this was so easy to understand. Thank You Striver ...
@paryt76962 жыл бұрын
1 upvote, best explaination brother, and congo for the offers from facebook and google, this news had definitely shut the mouth of haters
@shriyanshjain4444 Жыл бұрын
To be honest, this was the toughest video of the playlist so far, and obviously not the easiest! 100/100 for the efforts!
@deepakjain44819 ай бұрын
you are best man no one even touch these type of topics
@adityan53022 жыл бұрын
Almost completed my Binary Trees trees. If I get placed in a good company, the credit goes to you. Love you bro
@073.iyasmeenmahilang315 күн бұрын
You did?
@natanshisharma882812 күн бұрын
@@073.iyasmeenmahilang3 lol
@aryanchaurasia1081 Жыл бұрын
Amazingly explained ,the intuition has just fit into my head forever❤️
@mohitsingh77932 жыл бұрын
Crystal and Clear Explanation for such a difficult topic❤
@santanu29 Жыл бұрын
Great Explanation. A bit of a heavy topic, takes time to wrap your head around. Will revisit after a week.
@preetkatiyar9692 жыл бұрын
Best explanation. No one can explain better than this way.
@umber31177 ай бұрын
Best explanation.Thanks a lot for making these videos.
@anshumanprasad54102 жыл бұрын
thank you so much after struggling so much on this topic, I watched your video.
@saisardesai554823 күн бұрын
never seen an explaination like this wonderful!
@preetisahani505410 ай бұрын
Great! Very nicely explained!
@iamnoob759320 күн бұрын
Superb striver , Man ur excellent
@shreyashachoudhary4802 жыл бұрын
Really amazing explanation. Thanks. Though that AMORTIZED time complexity confuses a bit.
@mayankdham89172 жыл бұрын
Best explanation of morris traversal..
@stith_pragya9 ай бұрын
Thank You So Much for this wonderful video............🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
@SohamDutta2222 ай бұрын
YOU ARE THE BEST! THANK YOU.
@kashishsharma68092 жыл бұрын
Application of this algo = change links in tree ques. Eg flatten the tree ( next ques of this playlist). 👍👍
@surabhichoubey29872 жыл бұрын
Literally it was seems Soo horrible now it's seems so easy just because of you thanks a lot ❤️
@bharatht55952 жыл бұрын
Clear explanation from scratch. Thanks
@nagasrikuncharapu3736Ай бұрын
It took time to understand this, but it's worth it.
@devanshtiwari916311 ай бұрын
Great Explanation till now for Morris Traversal.
@sumitgupta3102 ай бұрын
what a amazing Explaination man!!
@AmolGautam8 ай бұрын
thank you for this explaination
@anmolswarnkar77072 жыл бұрын
This was very well explained, thanks a lot.
@Flash-qr5oh8 ай бұрын
he really made the code easy....
@jatinsalve3645 ай бұрын
Interviewer will ask this question like , do the traversal without using recursion or-any extraspace.
@gandhijainamgunvantkumar67832 жыл бұрын
Best explanation ever. bhaiya your explaining style is very very good.
@aviadshiber62322 жыл бұрын
Damn, that is so smart technique. thanks for the great explanation!
@amanali9501 Жыл бұрын
why there is a need to remove a thread ? if it exists on that element it mean its left side is visited , so one can go to right directly
@shwetanksingh52082 жыл бұрын
For post order Morris Traversal-> We will modify the preorder morris traversal from root->left->right to root->right->left. For this we need to do one more change. While in normal preorder and inorder, we were creating thread from right most node of left subtree to present node, here we will create thread from left most node of right subtree to present node as here we have to cover right subtree before left subtree class Solution { public: vector postorderTraversal(TreeNode* root) { vector ans; while(root) { TreeNode *curr = root;//We will create thread from left most node of right subtree to present node and will //travell to that node using curr if(curr->right)//if root has right child //We can't push directly this root node val to ans as we are not sure whether we are here //thorough thread link after covering right subtree or we are here for the first time { curr = curr->right; while(curr->left && curr->left != root)//go to left most node of right subtree curr=curr->left; if(curr->left != root)//not threaded yet { ans.push_back(root->val);//it means root was visited for first time and this is modified preorder hence //push this node's val to ans curr->left = root;//create the thread root = root->right;//go to right to cover right subtree as modified preorder is root->right->left } else//was threaded { curr->left = NULL;//break the thread root = root->left;//right subtree has been covered hence now cover the left one //no need to push this node value as we are here for the second time using thread //link } } else//root hasn't right child { ans.push_back(root->val);//modified preorder is root->right->left hence push this value before going to left root = root->left; } } reverse(ans.begin(),ans.end());//reversing root->right->left to left->right->root to make it post order return ans; } };
@AlbertoRodriguez-oe6jo2 жыл бұрын
This is not O(1) space complexity.
@shwetanksingh52082 жыл бұрын
@@AlbertoRodriguez-oe6jo do you consider storage space of ans in space complexity?
@Rajat_maurya2 жыл бұрын
thanks
@rkalyankumar Жыл бұрын
Best explanation of Morris traversals.
@Ktr_7923 ай бұрын
Nothing Better Than this explanation
@anshumansinghrajawat72422 жыл бұрын
Amazing explanation , keep the good work going🙌
@satyasaineelapala5704 ай бұрын
Amazing explanation
@shreyasnagabhushan4918 Жыл бұрын
this was amazing bro, u made the topic look like a cake walk
@VinodKumar-by4pt Жыл бұрын
One of the easiest explanation ever, Thank you strive Bhaiya❤
@iffatkhan5505 Жыл бұрын
couldnt find a code simpler than this on tbt....thanks a ton
@harshdeepak32812 жыл бұрын
great explanation!!! loving the tree series!!!
@garvitanagpal Жыл бұрын
You're pretty good at what you do.Keep going! :)
@MayankLC932 жыл бұрын
such a Awesome Expalanation!!! TYSM!!
@aviralgoel5709 Жыл бұрын
Actual video starts @2:10
@AyushSingh-em2il3 ай бұрын
Amazing!
@jaiminsolanki54782 жыл бұрын
Complex Concept made Simple, tysm Raj Bhaiya!!!
@ordinaryhomosapien11812 жыл бұрын
Such a wonderful Explanation
@anubhavpabby68562 жыл бұрын
Thank you bhaiya, this video helped me to learn this concept quickly
@devils_mercy2 ай бұрын
nice explanation
@TheHorseRaddish Жыл бұрын
Very clear explanation! Thanks!
@morhadi2 ай бұрын
The dopamine rush after your code runs on first try >>>
@huungryyyy29 күн бұрын
😁😊thanku striver bhai
@sudarshan39012 жыл бұрын
Amazing explanation !!! Loved it ...
@Aryan-fi2qf2 жыл бұрын
I am getting Runtime error when trying run code without removing thread, We are moving right of curr node as we reach the rightmost of left subtree of curr node, so why do we need to remove the thread?
@divyansh22122 жыл бұрын
We need to remove the thread because the thread pointing to the curr node and this is changing the structure of the tree
@user-tk2vg5jt3l4 ай бұрын
Thank you Bhaiya
@dishant930 Жыл бұрын
Thank you so much Striver got it thoroughly!
@ananthia521610 ай бұрын
Awesome❤❤❤🎉
@debjitmaji632 Жыл бұрын
Shouldn't the TC be 0(3N) .. N for whole traversal + N for making link + N for breaking link.. Plzz help!
@ooofrg449215 күн бұрын
After a lots of struggle I got it 😂
@kdoxfkck2 жыл бұрын
best explaination ever ever..... ❤️❤️🙂🙂
@Yash-uk8ib2 жыл бұрын
sir, is it possible to do postorder with morris??
@shyamalaravind5906 Жыл бұрын
Wonderful explanation. Please keep it up.
@SreeCharan-dx7oc6 ай бұрын
THANK YOU
@ygpointoffun941811 ай бұрын
what if striver we do not remove thread it will affect anymore??
@sathwikabhignan5535 Жыл бұрын
fantastic explanation sir it really helped me a lot😀😀
@KartikeyTT2 ай бұрын
ty sir
@kaustubhdwivedi1729 Жыл бұрын
Every time to rescue. Thank You !
@rohitraj9515Ай бұрын
does morris traversal is also for postorder?
@sanyummanhas19943 ай бұрын
at 4:26 what does he say a single kind of a Quadret??....i didnt quite get it, Can someone tell me what it is?