Count Balanced Binary Trees of Height h
Last updated
Last updated
Given a height h, count and return the maximum number of balanced binary trees possible with height h. A balanced binary tree is one in which for every node, the difference between heights of left and right subtree is not more than 1.
Examples :
Following are the balanced binary trees of height 3.
Height of tree, h = 1 + max(left height, right height) Since the difference between the heights of left and right subtree is not more than one, possible heights of left and right part can be one of the following:
(h-1), (h-2)
(h-2), (h-1)
(h-1), (h-1)