Finding the Maximum Depth of a Binary Tree (Recursion)

preview_player
Показать описание
Find the maximum depth of a binary tree using recursion. I show you the java code needed to get it done and go through the recursion visually to better understand it.

If you have any other videos you'd like me to create, please comment below. If theres anything I can do better let me know!

Like and Subscribe!!

All code can be found here:

ONeill Code's purpose is to provide in-depth tutorials on a wide range of programming material. It can focus on interview questions or simple algorithms depending on the user requests. If you have any video requests please let me!
Рекомендации по теме
Комментарии
Автор

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.

Sunshine-mjpf
Автор

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!

jacob.lee
Автор

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.

wperlich
Автор

You just cleared my confusion on how it would work recursively.
Thanks for the tips.

trinityimma
Автор

exactly what I was looking for ... thank you ONeill

kofi
Автор

I was struggling with recursion in tree and graph, your clear cut explanation made it very easy. Thanks:)

ankishbansal
Автор

the cleanest explanation I can find on youtube...especially about the recursion which trips me up all the time... a bunch thanks man ...

Gman-kxdr
Автор

Probably the best explanation of the recursive calls!! Thank You!!!

JamesHalpert
Автор

Awesome explanation. Most videos don't cover each step of the recursion.

jaepark
Автор

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.

hanxu
Автор

Thankyou very much for this walkthrough I needed this

sourabh
Автор

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.

navarroaccount
Автор

Thank you so much sir....Only video I found on youtube with explanation of recursion

pranjalpimpale
Автор

shouldnt the depth be 3 because there is only 3 edges from root to the deepest leaf?

krishnansnair
Автор

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!

KeenalShah
Автор

The visual explanation helped so much. Thanks!

wtfchazpwnt
Автор

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?

Richard-yzgy
Автор

Thank you so much - I finally understand how recursion works in a binary tree!

aimeewildstone
Автор

Thanks man. This is top level best explanation

theboy
Автор

Thanks!
It's really important to UNDERSTAND recursion and not try to memorize the small code snippets.

eyalpery