n -> it represent total number of nodes len -> it is the maximum length of array to hold parent of each node . In worst case , the highest value of parent a node can have is n - 1. 2 ^ len <= n - 1 len = O ( log2n )
int getLen ( int n ) { int len = ( int ) ( log ( n ) / log ( 2 ) ) + 1 ; return len ; }