Sorting a linked list
January 21, 2013
Printing border nodes of Binary Tree
January 24, 2013

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.

1 Comment

  1. CH RAJA SEKHAR says:

    Here its is an example for this question. Is there any mathematical proof regrading this problem

Leave a Reply

Your email address will not be published. Required fields are marked *