MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/o3fan0/check_if_binary_tree_is_balanced/h2fd99s/?context=3
r/badcode • u/MrPancholi • Jun 19 '21
44 comments sorted by
View all comments
2
Can’t you just traverse and check if any node has a single leaf node?
1 u/paulsmithkc 👨🏫 Jun 20 '21 You cannot. Two entire branches can be balanced in and of themselves. But if one has height 5 and the other height 3, the whole tree becomes imbalanced. 1 u/[deleted] Jun 20 '21 Ah I conflated “balanced” with “bushy” (I think that’s the word)
1
You cannot. Two entire branches can be balanced in and of themselves. But if one has height 5 and the other height 3, the whole tree becomes imbalanced.
1 u/[deleted] Jun 20 '21 Ah I conflated “balanced” with “bushy” (I think that’s the word)
Ah I conflated “balanced” with “bushy” (I think that’s the word)
2
u/[deleted] Jun 20 '21
Can’t you just traverse and check if any node has a single leaf node?