if we store the Binary tree in array as array[1] = x1 array[2] = x2 array[3] = x3 array[4] = x4 array[5]= x5 array[6]= x6 array[7]=x7
x1 is first node at level 0 root node x2 is left node and x3 is right node of x1 at level 1 x4 is left node and x5 is right node of x2 at level 2 and x5 is left node and x6 is right node of x3 at level 2 Now from the array index we can easily find the height of each node example x5 is at level log5/log2 = 2. which says node x5 is at level 2 On Tue, Jun 22, 2010 at 4:21 AM, divya <[email protected]> wrote: > give efficient way to store a tree in an array such that its height > can be calculated with ease requirements > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<algogeeks%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
