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 )
def getLen ( n ) : NEW_LINE INDENT len = int ( ( math . log ( n ) ) // ( math . log ( 2 ) ) ) + 1 NEW_LINE return len NEW_LINE DEDENT