My Own Notes: Sink Zeros in Binary Tree
Swap zero value of a node with non-zero value of one of its descendants so that no node with value zero could be parent of node with non-zero.Solution:
We use a postorder traversal of the tree where instead of sinking we rise the leafs, we keep the nodes that we are sure that have not a zero ancestor.Read full article from My Own Notes: Sink Zeros in Binary Tree
No comments:
Post a Comment