Browsing the archives for the trees tag

Balanced Tree

Tweet Question: How would you check if a binary tree is balanced? Answer: A tree is considered balanced when the difference between the min depth and max depth does not exceed 1. Recursive algorithms always work well on trees, so here’s some code. int min_depth( Node * root ) { if( !root ) { return […]