This is the first video I watched that explains the timeline of recursion, which is extremely helpful for people like me who is always confused by recursion process. Thanks a lot.
@jacob.lee3802 жыл бұрын
I've been watching more than 10 videos to understand how binary tree traversal and recursion work. This is the first video I truly understand both concepts! Thanks!
@wperlich7 жыл бұрын
Thanks for the explanation. I am practicing for interviews and these recursive solutions have a lot more depth than what meets the eye. I think it's important to run through the tree like this to have an understanding of what is going on at least on a conceptual level. It's all too tempting to just memorize the simple code. Keep up the good work.
@abhishekchaudhary39096 жыл бұрын
Cool video
@dark13angelxxx4 жыл бұрын
Did you get a job?
@trinityimma5 жыл бұрын
You just cleared my confusion on how it would work recursively. Thanks for the tips.
@parthyadav31774 жыл бұрын
i didnt understand could you explain pleasse
@kofi76174 жыл бұрын
exactly what I was looking for ... thank you ONeill
@lukelyu32643 жыл бұрын
The beeeeest recursion explanation ever!
@ankishbansal4205 жыл бұрын
I was struggling with recursion in tree and graph, your clear cut explanation made it very easy. Thanks:)
@go_cool_travels4 жыл бұрын
Same here bro do you overcome that now??
@Gman-kx9dr2 жыл бұрын
the cleanest explanation I can find on youtube...especially about the recursion which trips me up all the time... a bunch thanks man ...
@JamesHalpert85554 жыл бұрын
Probably the best explanation of the recursive calls!! Thank You!!!
@pranjalpimpale84654 жыл бұрын
Thank you so much sir....Only video I found on youtube with explanation of recursion
@aimeewildstone46023 жыл бұрын
Thank you so much - I finally understand how recursion works in a binary tree!
@navarroaccount20855 жыл бұрын
If the height of the root is 4, then he height of node 2 is 3, the height of node 5 is 2 and the height of node 6 is 1. It doesn't add up. The same happens with the height.
@hanxu21434 жыл бұрын
Thank you so much for explaining it in a visual way. I could not find a better video that explains how recursive navigation of a tree works. Keep up with the illustrations! Subscribed.
@jaepark15935 жыл бұрын
Awesome explanation. Most videos don't cover each step of the recursion.
@xavicfc15044 жыл бұрын
Thank you for the video, it is people like you, why we can understand difficult concepts, Thank you!
@sourabh35844 жыл бұрын
Thankyou very much for this walkthrough I needed this
@wtfchazpwnt4 жыл бұрын
The visual explanation helped so much. Thanks!
@KeenalShah4 жыл бұрын
Thank you!! This is exactly what I was looking for. I was getting a bit mixed up with how the recursion code was working, your explanation cleared it!
@sourabh35844 жыл бұрын
are u doing leetcode or gfg?
@KeenalShah4 жыл бұрын
@@sourabh3584 yup, leetcode!
@sourabh35844 жыл бұрын
@@KeenalShah would you like to do it with me, I'm doing interview prep!! you can find me on linked in
@KeenalShah4 жыл бұрын
@@sourabh3584 sure!
@abhishek.eswarappa3 жыл бұрын
@@sourabh3584 That was smooth Lol xD
@bennet54672 жыл бұрын
Excellent explanation. Thanks sir!
@eyalpery84703 жыл бұрын
Thanks! It's really important to UNDERSTAND recursion and not try to memorize the small code snippets.
@theboy4665 жыл бұрын
Thanks man. This is top level best explanation
@alexei17505 жыл бұрын
Awesome video for computer science lovers!!
@krishnansnair43866 жыл бұрын
shouldnt the depth be 3 because there is only 3 edges from root to the deepest leaf?
@johnnyweng11646 жыл бұрын
I think so. It is easier to get the depth by just using the definition of the tree depth than by doing the code analysis. The tricky part in code is adding one to the maximum of right and left. This one does not represent the node itself, but it means the edge between the node and its upper node.
@acxd4 жыл бұрын
Can you please explain various tree traversal methods using recursion.
@Richard-yz2gy Жыл бұрын
Hi Stephen, if "3.left" is None=0 from the right side of the tree then how can you put left= 3 in the final return statement surely it should be 0 because the last value for the varaible for "left" is 0 not 3 surely?
@AyushGupta-kp9xf4 жыл бұрын
thanks a lot for this explanation it was really much needed!
@joseluislopez7884 жыл бұрын
Thanks a lot, your explanation was amazing.
@chandlerlxw4 жыл бұрын
Thank you for the detailed explanation, really helpful for me! Subscribed
@ynidhypatia3 жыл бұрын
Woahh, this is the only video I've seen that starts the counting with one, the others started at zero
@steven346115 күн бұрын
I thought you counted edges for depth and height, not the nodes?
@rashmi_gaur4 жыл бұрын
Great explanation!!👍
@didoma734 жыл бұрын
this is excellent, thank you!
@tahakhan3963 Жыл бұрын
thanks a lot for the explanation
@rubenlech72564 жыл бұрын
Very good explanation...
@rathan235 Жыл бұрын
Great job
@darshmahra50483 жыл бұрын
so this would be considered an inorder traversal right?
@abajoaladerecha3 жыл бұрын
What if the top of the tree have more than one treeNode?
@prakharagrawal85474 жыл бұрын
nice explanation
@kingdavey874 жыл бұрын
Wow dude awesome video
@dweebosupremo59043 жыл бұрын
good explanation
@siriuz9279 Жыл бұрын
well explained
@sushantkshirsagar7 жыл бұрын
Amazing explanation. Thanks a lot
@abhinavreddy53504 жыл бұрын
Nice explaination bro Do more videos........:)
@Santi-iz1uo4 жыл бұрын
Shouldn't the height be 3? You count the edges not the nodes no?
@yangyu29506 жыл бұрын
wow this is great, thanks so much. awesome explanation too!
@ashleygautama45517 жыл бұрын
Thanks for explaining this so clearly. It's nice seeing what is going on behind the scenes. I have a question though: say I only have 1 node in my tree. If I use the recursion code you provided to calculate the depth I get a depth of 1. Shouldn't that be 0 because this node has no children? Or is my concept of depth wrong? Also as a novice I would not know how to solve this problem. Will I ever learn to produce these kind of solutions on my own or am I stuck copying code :( ? This seems quite difficult to come up with yourself and at the moment i'm stuck coping code from others with regard to binary trees.....
@ONeillCode7 жыл бұрын
Hey Ashley, great question! This will come down to the way you perceive solving the max depth and if you are asked to solve this problem you should as the following: Do you want me to calculate using the number of nodes from the root or number of edges from the root? Searching the internet you will see if shown both ways. In my example we calculated using nodes. When using the number of nodes we return 0 when we find a null root ( if(root == null) return 0; ). If you were to calculate using the number of edges (Max Height / Max Depth would be 3 instead of 4) you would return -1 when you find a null root ( if(root==null) return -1; ). This will return 0 just as you asked above. It comes down to how you perceive finding the max. And as for if you will ever learn, of course you will! After getting more experience programming, you will pick up on data structures and algorithms useful for solving certain types of problems. It just takes practice. Don't worry!
@ashleygautama45517 жыл бұрын
Thank you again for clearing that up, too and also for your encouraging words. I know how recursion works, but as seen in your video it sometimes is difficult to keep track at what it is it's doing and how you can solve certain problems with it. Keep up the good work!
@callmewave_6 жыл бұрын
The depth would be 1 because there is a level. You're thinking index. Look at the solution - if your depth with a single node would be zero, then the solution provided above should be 3.