DATA STRUCTURE
Programming and Technical
Programming
Technical
Consider a Binary tree having two pointer for its each children. These pointer are set to NULL if the corresponding child is empty . How many NULL pointer does a Binary Tree with N nodes have ? options are N,n+1,n-1,depend on the shape of the tree
Read Solution (Total 2)
-
- If there are in total N nodes including root. Then the Answer will be N+1.
Because every Node has 2 children.
=> total pointers in a tree of N nodes = 2*N
=> Every node except root node has 1 parent, therefore ,total parents = N-1
=> left nodes which are not a Parent Node i.e having null pointers = 2N -(N-1) = N+1
=> Answer = N+1 - 8 years agoHelpfull: Yes(8) No(0)
- n+1. from the def. of binary tree if there are n nodes. then no. of possible child nodes/leaf nodes=n-1.
suppose n=3, 1 is root node....2 child nodes eachhaving 2 pointers...therfore no of possble null pointers=2x4. Likewise....u can generlize it for complex structures - 8 years agoHelpfull: Yes(1) No(1)
DATA STRUCTURE Other Question