edited by
95 views
0 votes
0 votes

In a binary tree $T$, for a node $v$, the $\text{LEFT-HEIGHT} (v)$ is the length of the longest path from $v$ to any leaf in the left subtree of $v$. If $v$ has no left child then $\text{LEFT-HEIGHT} (v)=0$. The $\text{RIGHT-HEIGHT} (v)$ is defined accordingly.

A node $v$ is said to be properly balanced if $$ \mid \operatorname{LEFT-HEIGHT}(v)-\text { RIGHT-HEIGHT }(v) \mid \leq 1 \text {. } $$ Design an efficient algorithm that, given a binary tree, enumerates all the nodes which are properly balanced.

edited by

Please log in or register to answer this question.

Related questions

1 votes
1 votes
1 answer
1
1 votes
1 votes
1 answer
3
admin asked Aug 8, 2022
382 views
Consider a stack machine where the only available workspace is a stack whose elements are unsigned integers. We will denote the configuration of the stack by a sequence. ...