You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We could add simple checks to avoid unnecessary traversal in case of unbalanced tree.
For example if a node has no elements in its right subtree, it makes no sense to traverse its left subtree for levels higher than 1. So if we reach 2nd level in the left subtree, we already know that the tree is unbalanced.
Also after processing left subtree we have its height and we could limit the maximum depth of traversal for the right subtree to this value.
The text was updated successfully, but these errors were encountered:
We could add simple checks to avoid unnecessary traversal in case of unbalanced tree.
For example if a node has no elements in its right subtree, it makes no sense to traverse its left subtree for levels higher than 1. So if we reach 2nd level in the left subtree, we already know that the tree is unbalanced.
Also after processing left subtree we have its height and we could limit the maximum depth of traversal for the right subtree to this value.
The text was updated successfully, but these errors were encountered: