Complete Binary tree(CBT) and Almost Complete Binary tree(ACBT): Total nodes and formulae :

Connect with me on
Instagram        Twitter           LinkedIn             my website                facebook          Whatsapp             gmail

  Important  about CBT(complete binary tree) & ACBT(Almost complete binary tree)

let : k = level of tree, n = total nodes, ^ is power 

  • total nodes in CBT : 2(k-1)   
  • total nodes n : n =  2(k) – 1
  • in kth level CBT :    
                                leaf nodes  : (n/2) + 1;

                                 non leaf nodes : (n/2);
  • in CBT i k level , n nodes then :   
                           n  = 2(k) – 1  
                          n + 1 = 2(k) 
taking log both side with base 2 , 
                         k = Log2(n);
  • in a 10 level CBT : 
                            maximum nodes : 1023 (2(k) – 1)
                            minimum node :   1023 (2(k) – 1)


  • in a 10 level ACBT :
                        maximum nodes :   1023 (2(k) – 1)
                         minumum nodes : 512 
                        explanation :  first select the 9 levels i.e 511 (2(9) – 1)
                                                 then add  1 node that is present in 10th level .
                                                    so 511 +1 = 512 nodes

calculate using the following code  in the jdoodle ide :










Comments

Post a Comment

Popular posts from this blog

PERFECT SQUARE asked by MountainBlue

Harry and Porter asked in MountainBlue ,2022

Chomsky's hierarchy Explanation :