Single node have height 0.So, for height 6 tree should have 7 level as we have 7 values i.e. every level have exaclty 1 value to get tree of height 6.
to get this kind of tree every node should have either minimum or maximum of remaining node otherwise more than 1 node will be there at some levels.
so from 1 to 6 level we have 2 choices that is maximum or minimum of remaining values in the sequence and at last level we will have no choice as only 1 value will be left so it will be filled as it is in tree
this is how we got 2^6.
- At 1st level: remaining are 1,2,3,4,5,6,7
choice is 1 or 7 that is either max or min, suppose we took 1 as root.
- At 2nd level: remaining are 2,3,4,5,6,7
choice is 2 or 7 that is either max or min, suppose we took 7.
- At 3rd level: remaining are 2,3,4,5,6
choice is 2 or 6 that is either max or min, suppose we took 2.
- At 4rth level: remaining are 3,4,5,6
choice is 3 or 6 that is either max or min, suppose we took 3.
- At 5th level: remaining are 4,5,6
choice is 4 or 6 that is either max or min, suppose we took 6.
- At 6th level: remaining are 4,5
choice is 4 or 5 that is either max or min, suppose we took 4.
- At 7th level: remaining are 5
no choice i.e. single element remaining so take as it is.