Number of NULL pointers in a Binary Tree

Given a Binary Tree with n Nodes (you may arrange these nodes any way you want to). How many NULL pointers will be there ?

You want options also :)..

Here are the options

A) n         B) n+1         C) n-1         D) None


Solution:

The Answer is n+1.

No matter how you arrange n nodes in a binary tree, there will always be n+1 NULL pointers. for example, if n=3, then below are the possible arrangements of a Binary tree with 3 nodes, all the arrangements have 4 NULL pointers (marked 1,2,3,4)

You may try with any number of nodes in the tree, there will always be n+1 NULL pointers in a Binary tree with n Nodes.

0 Comments

Leave a comment