Bi-Tri tree

A special tree has two types of nodes: biNodes and triNodes :

  • Each biNode has either 0 or 2 children.
  • Each triNode has either 0 or 3 children.
  • All children (if any) of a biNode are triNodes .
  • All children (if any) of a triNode are biNodes .

The root node of the tree can be of either type. The tree is complete , that is to say, at any level every node has the same number of children.

The height of the Bi-Tri tree is defined as the number of edges from the root node to a leaf.

Bi-Tri Trees of Height 2 Bi-Tri Trees of Height 2

What is the maximum number of leaf nodes that a tree of this type of height 11 may have?

For example, if the height 2, then the answer will be 6.


The answer is 23328.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

As the root is the only node of height 0,so any node of height n will mean the node has n-1 more ancestors other than the root.It means it is in the n th level after the root. So if n is an even number, however the root is BiParent or TriParent, there will be 2 n / 2 3 n / 2 2^{n/2}*3^{n/2} leaves. If n is odd, if the root is BiParent then there will be 2 ( n + 1 ) / 2 3 ( n 1 ) / 2 2^{(n+1)/2}*3^{(n-1)/2} leaves,else the root is TriParent then there will be 2 ( n 1 ) / 2 3 ( n + 1 ) / 2 2^{(n-1)/2}*3^{(n+1)/2} leaves. So number of leaves will be maximized if the root is TriParent.

Here n=11 which is odd. So the maximum leaf number would be 2 ( 11 1 ) / 2 3 ( 11 + 1 ) / 2 2^{(11-1)/2}*3^{(11+1)/2} = 2 5 3 6 2^{5}*3^{6} =23328

Md Ashiqur Rahman
Aug 22, 2016

a simple recursion . my c++ code may work well as solution .

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#include<iostream>
using namespace std;
int number( int i)
{

    if(i==0) return 1;
    else return (i%2+2)*number(i-1);
}
int main()
{

    cout<<number(11)<<endl;
    return 0;

}

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...