A binary tree is foldable if the left subtree and right subtree are mirror images of each other. An empty tree is also foldable. Below binary trees are foldable since both have a left subtree that is the mirror image of right subtree.


However, below binary tree is not foldable.

We can check if a binary tree is foldable or not in two ways:
By changing the left subtree to its mirror equivalent. Then checking if the mirror is equivalent to te right subtree.Compare and check if right and left s...
Published on March 26, 2021 09:54