0

Given number of nodes N (ie a preorder seq of length N) in a balanced binary tree,I am trying to find the number b of possible balanced binary trees that can be formed.

I noticed it is possible that there might be variations in the leaves as well as the higher-level nodes:

         A
       /   \
      B     C  
     /     / \  
    D     E   F  
         /  
        G  

The constraint is generally applied recursively to every subtree. That is, the tree is only balanced if:

1.The left and right subtrees' heights differ by at most one, AND
2.The left subtree is balanced, AND
3.The right subtree is balanced

User756
  • 13
  • 7
  • Hello and welcome to StackOverflow. Please take some time to read the help page, especially the sections named ["What topics can I ask about here?"](http://stackoverflow.com/help/on-topic) and ["What types of questions should I avoid asking?"](http://stackoverflow.com/help/dont-ask). And more importantly, please read [the Stack Overflow question checklist](http://meta.stackexchange.com/q/156810/204922). You might also want to learn about [Minimal, Complete, and Verifiable Examples](http://stackoverflow.com/help/mcve). – n. m. could be an AI Mar 18 '17 at 06:36
  • please define "balanced tree". – Henry Mar 18 '17 at 07:03
  • Done! I am taking the example from here http://stackoverflow.com/questions/8015630/definition-of-a-balanced-tree – User756 Mar 18 '17 at 07:10
  • Are two balanced trees considered to be the same tree if one is formed by relabelling the vertices of the other? Are they the same tree if one is formed by exchanging the left and right subtrees of the other? – Angela Pretorius Mar 18 '17 at 16:13
  • The actual question actually says a preorder seq of n is there.So no one can not do that.Let me correct the q.Thanks – User756 Mar 18 '17 at 18:30

0 Answers0