N
     /      \
    N       N
   /  \      /   \
  N   L   N    L
  / \      /   \
L    L   L    L

 preorder  is given

build_CBT(node * root)
{
   if(node==null)
   print it is CBT;
   return;


  if(node->left ==NULL ||  node->right==NULL)
  print "impossible";
  return;


  if(node!=NULL)
  {  put(node.data)=N;

  if(node->left ==NULL && node->right==NULL)
  put (node->left)=node->right=L;
  return;

 }

  if(node->left!=NULL)
  {
      put(node->left->data=N;
     build_CBT(node->left);
 }

  ifnode->right!=NULL)
   {

      put(node->right->data=N;
     build_CBT(node->right);

  }

}

I Tried to Solve this....Please Write Comment If You Find Anything
Missing or Algo is Wrong..or How We Can  produce Exact Solution from
this..algo..because m again tellin its very important question in
amazon..they..wants exact working code.for this program...so have a
closer look at it again....

Might b i m missin sumthing here...so let know.

Thanks & Regards
Shashank Mani "Don't  B Evil U  Can Earn While U Learn "

-- 
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.

Reply via email to