[algogeeks] amazon test question!!!

2011-08-08 Thread rohit
What will the following code snippet do, when is it passed the root of
a binary tree ?
func( Node *node){

  if(node-right != NULL)

   func( node-right);

  if(node-left != NULL)

func( node-left);

  if( node-left == NULL  node-right == NULL )

 delete(node);

}

Pick choice
Delete the tree from bottom to top

Delete the tree from top to bottom

Delete the leaf nodes from right to left

Delete the leaf nodes from left to right

I think it is 3

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] amazon test question!!!

2011-08-08 Thread Akash Mukherjee
i think its 1 though ...

On Mon, Aug 8, 2011 at 10:21 PM, rohit rajuljain...@gmail.com wrote:

 What will the following code snippet do, when is it passed the root of
 a binary tree ?
 func( Node *node){

  if(node-right != NULL)

   func( node-right);

  if(node-left != NULL)

func( node-left);

  if( node-left == NULL  node-right == NULL )

 delete(node);

 }

 Pick choice
 Delete the tree from bottom to top

 Delete the tree from top to bottom

 Delete the leaf nodes from right to left

 Delete the leaf nodes from left to right

 I think it is 3

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] amazon test question!!!

2011-08-08 Thread rajul jain
got it thanks


On Mon, Aug 8, 2011 at 10:30 PM, Akash Mukherjee akash...@gmail.com wrote:

 i think its 1 though ...


 On Mon, Aug 8, 2011 at 10:21 PM, rohit rajuljain...@gmail.com wrote:

 What will the following code snippet do, when is it passed the root of
 a binary tree ?
 func( Node *node){

  if(node-right != NULL)

   func( node-right);

  if(node-left != NULL)

func( node-left);

  if( node-left == NULL  node-right == NULL )

 delete(node);

 }

 Pick choice
 Delete the tree from bottom to top

 Delete the tree from top to bottom

 Delete the leaf nodes from right to left

 Delete the leaf nodes from left to right

 I think it is 3

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] amazon test question!!!

2011-08-08 Thread pankaj kumar
what's ans

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] amazon test question!!!

2011-08-08 Thread Debabrata Das
i think 3

On Mon, Aug 8, 2011 at 10:32 PM, rajul jain rajuljain...@gmail.com wrote:
 got it thanks

 On Mon, Aug 8, 2011 at 10:30 PM, Akash Mukherjee akash...@gmail.com wrote:

 i think its 1 though ...

 On Mon, Aug 8, 2011 at 10:21 PM, rohit rajuljain...@gmail.com wrote:

 What will the following code snippet do, when is it passed the root of
 a binary tree ?
 func( Node *node){

  if(node-right != NULL)

       func( node-right);

  if(node-left != NULL)

        func( node-left);

  if( node-left == NULL  node-right == NULL )

     delete(node);

 }

 Pick choice
 Delete the tree from bottom to top

 Delete the tree from top to bottom

 Delete the leaf nodes from right to left

 Delete the leaf nodes from left to right

 I think it is 3

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] amazon test question!!!

2011-08-08 Thread rajul jain
I have also made same answer on first look but read 3rd  option correctly it
say deletion of leaves from right to left not internal nodes.

On Mon, Aug 8, 2011 at 10:36 PM, Debabrata Das 
debabrata.barunhal...@gmail.com wrote:

 i think 3

 On Mon, Aug 8, 2011 at 10:32 PM, rajul jain rajuljain...@gmail.com
 wrote:
  got it thanks
 
  On Mon, Aug 8, 2011 at 10:30 PM, Akash Mukherjee akash...@gmail.com
 wrote:
 
  i think its 1 though ...
 
  On Mon, Aug 8, 2011 at 10:21 PM, rohit rajuljain...@gmail.com wrote:
 
  What will the following code snippet do, when is it passed the root of
  a binary tree ?
  func( Node *node){
 
   if(node-right != NULL)
 
func( node-right);
 
   if(node-left != NULL)
 
 func( node-left);
 
   if( node-left == NULL  node-right == NULL )
 
  delete(node);
 
  }
 
  Pick choice
  Delete the tree from bottom to top
 
  Delete the tree from top to bottom
 
  Delete the leaf nodes from right to left
 
  Delete the leaf nodes from left to right
 
  I think it is 3
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
  --
  You received this message because you are subscribed to the Google Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] amazon test question!!!

2011-08-08 Thread Debabrata Das
check this condition
if( node-left == NULL  node-right == NULL )
it is true only for leaves node

On Mon, Aug 8, 2011 at 10:46 PM, rajul jain rajuljain...@gmail.com wrote:
 I have also made same answer on first look but read 3rd  option correctly it
 say deletion of leaves from right to left not internal nodes.

 On Mon, Aug 8, 2011 at 10:36 PM, Debabrata Das
 debabrata.barunhal...@gmail.com wrote:

 i think 3

 On Mon, Aug 8, 2011 at 10:32 PM, rajul jain rajuljain...@gmail.com
 wrote:
  got it thanks
 
  On Mon, Aug 8, 2011 at 10:30 PM, Akash Mukherjee akash...@gmail.com
  wrote:
 
  i think its 1 though ...
 
  On Mon, Aug 8, 2011 at 10:21 PM, rohit rajuljain...@gmail.com wrote:
 
  What will the following code snippet do, when is it passed the root of
  a binary tree ?
  func( Node *node){
 
   if(node-right != NULL)
 
        func( node-right);
 
   if(node-left != NULL)
 
         func( node-left);
 
   if( node-left == NULL  node-right == NULL )
 
      delete(node);
 
  }
 
  Pick choice
  Delete the tree from bottom to top
 
  Delete the tree from top to bottom
 
  Delete the leaf nodes from right to left
 
  Delete the leaf nodes from left to right
 
  I think it is 3
 
  --
  You received this message because you are subscribed to the Google
  Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
  --
  You received this message because you are subscribed to the Google
  Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
  --
  You received this message because you are subscribed to the Google
  Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] amazon test question!!!

2011-08-08 Thread rajul jain
after deletion of leaf parent become leaf of parent's parent. so parent of
leaf would also delete I think

On Mon, Aug 8, 2011 at 10:49 PM, Debabrata Das 
debabrata.barunhal...@gmail.com wrote:

 check this condition
 if( node-left == NULL  node-right == NULL )
 it is true only for leaves node

 On Mon, Aug 8, 2011 at 10:46 PM, rajul jain rajuljain...@gmail.com
 wrote:
  I have also made same answer on first look but read 3rd  option correctly
 it
  say deletion of leaves from right to left not internal nodes.
 
  On Mon, Aug 8, 2011 at 10:36 PM, Debabrata Das
  debabrata.barunhal...@gmail.com wrote:
 
  i think 3
 
  On Mon, Aug 8, 2011 at 10:32 PM, rajul jain rajuljain...@gmail.com
  wrote:
   got it thanks
  
   On Mon, Aug 8, 2011 at 10:30 PM, Akash Mukherjee akash...@gmail.com
   wrote:
  
   i think its 1 though ...
  
   On Mon, Aug 8, 2011 at 10:21 PM, rohit rajuljain...@gmail.com
 wrote:
  
   What will the following code snippet do, when is it passed the root
 of
   a binary tree ?
   func( Node *node){
  
if(node-right != NULL)
  
 func( node-right);
  
if(node-left != NULL)
  
  func( node-left);
  
if( node-left == NULL  node-right == NULL )
  
   delete(node);
  
   }
  
   Pick choice
   Delete the tree from bottom to top
  
   Delete the tree from top to bottom
  
   Delete the leaf nodes from right to left
  
   Delete the leaf nodes from left to right
  
   I think it is 3
  
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
  
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
  --
  You received this message because you are subscribed to the Google Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] amazon test question!!!

2011-08-08 Thread sukran dhawan
deletes all nodes in the tree.basically it tarverses in postorder and when
it is a leaf it deletes the node

On Mon, Aug 8, 2011 at 10:21 PM, rohit rajuljain...@gmail.com wrote:

 What will the following code snippet do, when is it passed the root of
 a binary tree ?
 func( Node *node){

  if(node-right != NULL)

   func( node-right);

  if(node-left != NULL)

func( node-left);

  if( node-left == NULL  node-right == NULL )

 delete(node);

 }

 Pick choice
 Delete the tree from bottom to top

 Delete the tree from top to bottom

 Delete the leaf nodes from right to left

 Delete the leaf nodes from left to right

 I think it is 3

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] amazon test question!!!

2011-08-08 Thread aditi garg
@debrata : bt remember its a recursive function...once the leaf node gets
deleted thn it will move bak to the node and thn to the left of it
fr eg
  a
   /\
  b c
/  \/  \
   d   e  f   g
frst g will be deleted...then f thn it wil delete c and so on...i think the
ans shud be 1...correct me if i am wrong...
On Mon, Aug 8, 2011 at 10:49 PM, Debabrata Das 
debabrata.barunhal...@gmail.com wrote:

 check this condition
 if( node-left == NULL  node-right == NULL )
 it is true only for leaves node

 On Mon, Aug 8, 2011 at 10:46 PM, rajul jain rajuljain...@gmail.com
 wrote:
  I have also made same answer on first look but read 3rd  option correctly
 it
  say deletion of leaves from right to left not internal nodes.
 
  On Mon, Aug 8, 2011 at 10:36 PM, Debabrata Das
  debabrata.barunhal...@gmail.com wrote:
 
  i think 3
 
  On Mon, Aug 8, 2011 at 10:32 PM, rajul jain rajuljain...@gmail.com
  wrote:
   got it thanks
  
   On Mon, Aug 8, 2011 at 10:30 PM, Akash Mukherjee akash...@gmail.com
   wrote:
  
   i think its 1 though ...
  
   On Mon, Aug 8, 2011 at 10:21 PM, rohit rajuljain...@gmail.com
 wrote:
  
   What will the following code snippet do, when is it passed the root
 of
   a binary tree ?
   func( Node *node){
  
if(node-right != NULL)
  
 func( node-right);
  
if(node-left != NULL)
  
  func( node-left);
  
if( node-left == NULL  node-right == NULL )
  
   delete(node);
  
   }
  
   Pick choice
   Delete the tree from bottom to top
  
   Delete the tree from top to bottom
  
   Delete the leaf nodes from right to left
  
   Delete the leaf nodes from left to right
  
   I think it is 3
  
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
  
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
  --
  You received this message because you are subscribed to the Google Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Aditi Garg
Undergraduate Student
Electronics  Communication Divison
NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
Sector 3, Dwarka
New Delhi

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] amazon test question!!!

2011-08-08 Thread siddharam suresh
i feel ans is 1
Thank you,
Siddharam


On Mon, Aug 8, 2011 at 10:56 PM, sukran dhawan sukrandha...@gmail.comwrote:

 deletes all nodes in the tree.basically it tarverses in postorder and when
 it is a leaf it deletes the node

 On Mon, Aug 8, 2011 at 10:21 PM, rohit rajuljain...@gmail.com wrote:

 What will the following code snippet do, when is it passed the root of
 a binary tree ?
 func( Node *node){

  if(node-right != NULL)

   func( node-right);

  if(node-left != NULL)

func( node-left);

  if( node-left == NULL  node-right == NULL )

 delete(node);

 }

 Pick choice
 Delete the tree from bottom to top

 Delete the tree from top to bottom

 Delete the leaf nodes from right to left

 Delete the leaf nodes from left to right

 I think it is 3

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] amazon test question!!!

2011-08-08 Thread rajul jain
This is what i am trying to say to debabrata

On Mon, Aug 8, 2011 at 10:56 PM, aditi garg aditi.garg.6...@gmail.comwrote:

 @debrata : bt remember its a recursive function...once the leaf node gets
 deleted thn it will move bak to the node and thn to the left of it
 fr eg
   a
/\
   b c
 /  \/  \
d   e  f   g
 frst g will be deleted...then f thn it wil delete c and so on...i think the
 ans shud be 1...correct me if i am wrong...
 On Mon, Aug 8, 2011 at 10:49 PM, Debabrata Das 
 debabrata.barunhal...@gmail.com wrote:

 check this condition
 if( node-left == NULL  node-right == NULL )
 it is true only for leaves node

 On Mon, Aug 8, 2011 at 10:46 PM, rajul jain rajuljain...@gmail.com
 wrote:
  I have also made same answer on first look but read 3rd  option
 correctly it
  say deletion of leaves from right to left not internal nodes.
 
  On Mon, Aug 8, 2011 at 10:36 PM, Debabrata Das
  debabrata.barunhal...@gmail.com wrote:
 
  i think 3
 
  On Mon, Aug 8, 2011 at 10:32 PM, rajul jain rajuljain...@gmail.com
  wrote:
   got it thanks
  
   On Mon, Aug 8, 2011 at 10:30 PM, Akash Mukherjee akash...@gmail.com
 
   wrote:
  
   i think its 1 though ...
  
   On Mon, Aug 8, 2011 at 10:21 PM, rohit rajuljain...@gmail.com
 wrote:
  
   What will the following code snippet do, when is it passed the root
 of
   a binary tree ?
   func( Node *node){
  
if(node-right != NULL)
  
 func( node-right);
  
if(node-left != NULL)
  
  func( node-left);
  
if( node-left == NULL  node-right == NULL )
  
   delete(node);
  
   }
  
   Pick choice
   Delete the tree from bottom to top
  
   Delete the tree from top to bottom
  
   Delete the leaf nodes from right to left
  
   Delete the leaf nodes from left to right
  
   I think it is 3
  
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
  
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Aditi Garg
 Undergraduate Student
 Electronics  Communication Divison
 NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
 Sector 3, Dwarka
 New Delhi


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] amazon test question!!!

2011-08-08 Thread Debabrata Das
@aditi , yes you r right... i missed out delete(node) would make parent as leaf

On Mon, Aug 8, 2011 at 11:03 PM, rajul jain rajuljain...@gmail.com wrote:
 This is what i am trying to say to debabrata

 On Mon, Aug 8, 2011 at 10:56 PM, aditi garg aditi.garg.6...@gmail.com
 wrote:

 @debrata : bt remember its a recursive function...once the leaf node gets
 deleted thn it will move bak to the node and thn to the left of it
 fr eg
           a
        /    \
       b     c
     /  \    /  \
    d   e  f   g
 frst g will be deleted...then f thn it wil delete c and so on...i think
 the ans shud be 1...correct me if i am wrong...
 On Mon, Aug 8, 2011 at 10:49 PM, Debabrata Das
 debabrata.barunhal...@gmail.com wrote:

 check this condition
 if( node-left == NULL  node-right == NULL )
 it is true only for leaves node

 On Mon, Aug 8, 2011 at 10:46 PM, rajul jain rajuljain...@gmail.com
 wrote:
  I have also made same answer on first look but read 3rd  option
  correctly it
  say deletion of leaves from right to left not internal nodes.
 
  On Mon, Aug 8, 2011 at 10:36 PM, Debabrata Das
  debabrata.barunhal...@gmail.com wrote:
 
  i think 3
 
  On Mon, Aug 8, 2011 at 10:32 PM, rajul jain rajuljain...@gmail.com
  wrote:
   got it thanks
  
   On Mon, Aug 8, 2011 at 10:30 PM, Akash Mukherjee
   akash...@gmail.com
   wrote:
  
   i think its 1 though ...
  
   On Mon, Aug 8, 2011 at 10:21 PM, rohit rajuljain...@gmail.com
   wrote:
  
   What will the following code snippet do, when is it passed the
   root of
   a binary tree ?
   func( Node *node){
  
    if(node-right != NULL)
  
         func( node-right);
  
    if(node-left != NULL)
  
          func( node-left);
  
    if( node-left == NULL  node-right == NULL )
  
       delete(node);
  
   }
  
   Pick choice
   Delete the tree from bottom to top
  
   Delete the tree from top to bottom
  
   Delete the leaf nodes from right to left
  
   Delete the leaf nodes from left to right
  
   I think it is 3
  
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
  
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
 
  --
  You received this message because you are subscribed to the Google
  Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
  --
  You received this message because you are subscribed to the Google
  Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Aditi Garg
 Undergraduate Student
 Electronics  Communication Divison
 NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
 Sector 3, Dwarka
 New Delhi

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 

Re: [algogeeks] amazon test question!!!

2011-08-08 Thread siddharam suresh
func( Node *node){

if( node-left == NULL  node-right == NULL )

delete(node);

if(node-right != NULL)

  func( node-right);

 if(node-left != NULL)

   func( node-left);


}

for this code option 3 is correct

Thank you,
Siddharam


On Mon, Aug 8, 2011 at 11:03 PM, rajul jain rajuljain...@gmail.com wrote:

 This is what i am trying to say to debabrata


 On Mon, Aug 8, 2011 at 10:56 PM, aditi garg aditi.garg.6...@gmail.comwrote:

 @debrata : bt remember its a recursive function...once the leaf node gets
 deleted thn it will move bak to the node and thn to the left of it
 fr eg
   a
/\
   b c
 /  \/  \
d   e  f   g
 frst g will be deleted...then f thn it wil delete c and so on...i think
 the ans shud be 1...correct me if i am wrong...
 On Mon, Aug 8, 2011 at 10:49 PM, Debabrata Das 
 debabrata.barunhal...@gmail.com wrote:

 check this condition
 if( node-left == NULL  node-right == NULL )
 it is true only for leaves node

 On Mon, Aug 8, 2011 at 10:46 PM, rajul jain rajuljain...@gmail.com
 wrote:
  I have also made same answer on first look but read 3rd  option
 correctly it
  say deletion of leaves from right to left not internal nodes.
 
  On Mon, Aug 8, 2011 at 10:36 PM, Debabrata Das
  debabrata.barunhal...@gmail.com wrote:
 
  i think 3
 
  On Mon, Aug 8, 2011 at 10:32 PM, rajul jain rajuljain...@gmail.com
  wrote:
   got it thanks
  
   On Mon, Aug 8, 2011 at 10:30 PM, Akash Mukherjee 
 akash...@gmail.com
   wrote:
  
   i think its 1 though ...
  
   On Mon, Aug 8, 2011 at 10:21 PM, rohit rajuljain...@gmail.com
 wrote:
  
   What will the following code snippet do, when is it passed the
 root of
   a binary tree ?
   func( Node *node){
  
if(node-right != NULL)
  
 func( node-right);
  
if(node-left != NULL)
  
  func( node-left);
  
if( node-left == NULL  node-right == NULL )
  
   delete(node);
  
   }
  
   Pick choice
   Delete the tree from bottom to top
  
   Delete the tree from top to bottom
  
   Delete the leaf nodes from right to left
  
   Delete the leaf nodes from left to right
  
   I think it is 3
  
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
  
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Aditi Garg
 Undergraduate Student
 Electronics  Communication Divison
 NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
 Sector 3, Dwarka
 New Delhi


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe 

Re: [algogeeks] amazon test question!!!

2011-08-08 Thread *$*
I guess option 1 is correct

Thx,
--Gopi

On Mon, Aug 8, 2011 at 11:07 PM, siddharam suresh
siddharam@gmail.comwrote:

 func( Node *node){

 if( node-left == NULL  node-right == NULL )

 delete(node);

 if(node-right != NULL)

   func( node-right);

  if(node-left != NULL)

func( node-left);


 }

 for this code option 3 is correct

 Thank you,
 Siddharam



 On Mon, Aug 8, 2011 at 11:03 PM, rajul jain rajuljain...@gmail.comwrote:

 This is what i am trying to say to debabrata


 On Mon, Aug 8, 2011 at 10:56 PM, aditi garg aditi.garg.6...@gmail.comwrote:

 @debrata : bt remember its a recursive function...once the leaf node gets
 deleted thn it will move bak to the node and thn to the left of it
 fr eg
   a
/\
   b c
 /  \/  \
d   e  f   g
 frst g will be deleted...then f thn it wil delete c and so on...i think
 the ans shud be 1...correct me if i am wrong...
 On Mon, Aug 8, 2011 at 10:49 PM, Debabrata Das 
 debabrata.barunhal...@gmail.com wrote:

 check this condition
 if( node-left == NULL  node-right == NULL )
 it is true only for leaves node

 On Mon, Aug 8, 2011 at 10:46 PM, rajul jain rajuljain...@gmail.com
 wrote:
  I have also made same answer on first look but read 3rd  option
 correctly it
  say deletion of leaves from right to left not internal nodes.
 
  On Mon, Aug 8, 2011 at 10:36 PM, Debabrata Das
  debabrata.barunhal...@gmail.com wrote:
 
  i think 3
 
  On Mon, Aug 8, 2011 at 10:32 PM, rajul jain rajuljain...@gmail.com
  wrote:
   got it thanks
  
   On Mon, Aug 8, 2011 at 10:30 PM, Akash Mukherjee 
 akash...@gmail.com
   wrote:
  
   i think its 1 though ...
  
   On Mon, Aug 8, 2011 at 10:21 PM, rohit rajuljain...@gmail.com
 wrote:
  
   What will the following code snippet do, when is it passed the
 root of
   a binary tree ?
   func( Node *node){
  
if(node-right != NULL)
  
 func( node-right);
  
if(node-left != NULL)
  
  func( node-left);
  
if( node-left == NULL  node-right == NULL )
  
   delete(node);
  
   }
  
   Pick choice
   Delete the tree from bottom to top
  
   Delete the tree from top to bottom
  
   Delete the leaf nodes from right to left
  
   Delete the leaf nodes from left to right
  
   I think it is 3
  
   --
   You received this message because you are subscribed to the
 Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
  
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 

 --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Aditi Garg
 Undergraduate Student
 Electronics  Communication Divison
 NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
 Sector 3, Dwarka
 New Delhi


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are 

Re: [algogeeks] amazon test question!!!

2011-08-08 Thread raj kumar
answer is three although the nodes are delted but the pointer of nodes other
than leaves are not set to null

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] amazon test question!!!

2011-08-08 Thread sagar pareek
Option 3 is correct :-

suppose we have tree

   a
   / \
/   \
 b  c
   /   \   /\
d  e   fg

now it will first delete g
then it will delete f
 now why would it delete c ?
we are deleting f and g because both left and right are NULL of f and g

but still c-left and c-right has address of f and g respectively (dangling
pointer ) but if we check the condition (c-left==NULLc-right==NULL) , it
will not satisfy hence c will not be deleted...

so we  we have to do c-left=NULL and c-right=NULL before deleting

pls correct me if i m wrong



On Mon, Aug 8, 2011 at 11:23 PM, *$* gopi.komand...@gmail.com wrote:

 I guess option 1 is correct

 Thx,
 --Gopi


 On Mon, Aug 8, 2011 at 11:07 PM, siddharam suresh siddharam@gmail.com
  wrote:

 func( Node *node){

 if( node-left == NULL  node-right == NULL )

 delete(node);

 if(node-right != NULL)

   func( node-right);

  if(node-left != NULL)

func( node-left);


 }

 for this code option 3 is correct

 Thank you,
  Siddharam



 On Mon, Aug 8, 2011 at 11:03 PM, rajul jain rajuljain...@gmail.comwrote:

 This is what i am trying to say to debabrata


 On Mon, Aug 8, 2011 at 10:56 PM, aditi garg 
 aditi.garg.6...@gmail.comwrote:

 @debrata : bt remember its a recursive function...once the leaf node
 gets deleted thn it will move bak to the node and thn to the left of it
 fr eg
   a
/\
   b c
 /  \/  \
d   e  f   g
 frst g will be deleted...then f thn it wil delete c and so on...i think
 the ans shud be 1...correct me if i am wrong...
 On Mon, Aug 8, 2011 at 10:49 PM, Debabrata Das 
 debabrata.barunhal...@gmail.com wrote:

 check this condition
 if( node-left == NULL  node-right == NULL )
 it is true only for leaves node

 On Mon, Aug 8, 2011 at 10:46 PM, rajul jain rajuljain...@gmail.com
 wrote:
  I have also made same answer on first look but read 3rd  option
 correctly it
  say deletion of leaves from right to left not internal nodes.
 
  On Mon, Aug 8, 2011 at 10:36 PM, Debabrata Das
  debabrata.barunhal...@gmail.com wrote:
 
  i think 3
 
  On Mon, Aug 8, 2011 at 10:32 PM, rajul jain rajuljain...@gmail.com
 
  wrote:
   got it thanks
  
   On Mon, Aug 8, 2011 at 10:30 PM, Akash Mukherjee 
 akash...@gmail.com
   wrote:
  
   i think its 1 though ...
  
   On Mon, Aug 8, 2011 at 10:21 PM, rohit rajuljain...@gmail.com
 wrote:
  
   What will the following code snippet do, when is it passed the
 root of
   a binary tree ?
   func( Node *node){
  
if(node-right != NULL)
  
 func( node-right);
  
if(node-left != NULL)
  
  func( node-left);
  
if( node-left == NULL  node-right == NULL )
  
   delete(node);
  
   }
  
   Pick choice
   Delete the tree from bottom to top
  
   Delete the tree from top to bottom
  
   Delete the leaf nodes from right to left
  
   Delete the leaf nodes from left to right
  
   I think it is 3
  
   --
   You received this message because you are subscribed to the
 Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com
 .
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
  
   --
   You received this message because you are subscribed to the
 Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 

 --
 You received this message because you are subscribed to the 

Re: [algogeeks] amazon test question!!!

2011-08-08 Thread aditi garg
when f and g have been deleted wudnt the last condition left==null
right==null be satisfied fr c as well?

On Tue, Aug 9, 2011 at 12:01 AM, sagar pareek sagarpar...@gmail.com wrote:

 Option 3 is correct :-

 suppose we have tree

a
/ \
 /   \
  b  c
/   \   /\
 d  e   fg

 now it will first delete g
 then it will delete f
  now why would it delete c ?
 we are deleting f and g because both left and right are NULL of f and g

 but still c-left and c-right has address of f and g respectively
 (dangling pointer ) but if we check the condition
 (c-left==NULLc-right==NULL) , it will not satisfy hence c will not be
 deleted...

 so we  we have to do c-left=NULL and c-right=NULL before deleting

 pls correct me if i m wrong



 On Mon, Aug 8, 2011 at 11:23 PM, *$* gopi.komand...@gmail.com wrote:

 I guess option 1 is correct

 Thx,
 --Gopi


 On Mon, Aug 8, 2011 at 11:07 PM, siddharam suresh 
 siddharam@gmail.com wrote:

 func( Node *node){

 if( node-left == NULL  node-right == NULL )

 delete(node);

 if(node-right != NULL)

   func( node-right);

  if(node-left != NULL)

func( node-left);


 }

 for this code option 3 is correct

 Thank you,
  Siddharam



 On Mon, Aug 8, 2011 at 11:03 PM, rajul jain rajuljain...@gmail.comwrote:

 This is what i am trying to say to debabrata


 On Mon, Aug 8, 2011 at 10:56 PM, aditi garg 
 aditi.garg.6...@gmail.comwrote:

 @debrata : bt remember its a recursive function...once the leaf node
 gets deleted thn it will move bak to the node and thn to the left of it
 fr eg
   a
/\
   b c
 /  \/  \
d   e  f   g
 frst g will be deleted...then f thn it wil delete c and so on...i think
 the ans shud be 1...correct me if i am wrong...
 On Mon, Aug 8, 2011 at 10:49 PM, Debabrata Das 
 debabrata.barunhal...@gmail.com wrote:

 check this condition
 if( node-left == NULL  node-right == NULL )
 it is true only for leaves node

 On Mon, Aug 8, 2011 at 10:46 PM, rajul jain rajuljain...@gmail.com
 wrote:
  I have also made same answer on first look but read 3rd  option
 correctly it
  say deletion of leaves from right to left not internal nodes.
 
  On Mon, Aug 8, 2011 at 10:36 PM, Debabrata Das
  debabrata.barunhal...@gmail.com wrote:
 
  i think 3
 
  On Mon, Aug 8, 2011 at 10:32 PM, rajul jain 
 rajuljain...@gmail.com
  wrote:
   got it thanks
  
   On Mon, Aug 8, 2011 at 10:30 PM, Akash Mukherjee 
 akash...@gmail.com
   wrote:
  
   i think its 1 though ...
  
   On Mon, Aug 8, 2011 at 10:21 PM, rohit rajuljain...@gmail.com
 wrote:
  
   What will the following code snippet do, when is it passed the
 root of
   a binary tree ?
   func( Node *node){
  
if(node-right != NULL)
  
 func( node-right);
  
if(node-left != NULL)
  
  func( node-left);
  
if( node-left == NULL  node-right == NULL )
  
   delete(node);
  
   }
  
   Pick choice
   Delete the tree from bottom to top
  
   Delete the tree from top to bottom
  
   Delete the leaf nodes from right to left
  
   Delete the leaf nodes from left to right
  
   I think it is 3
  
   --

   You received this message because you are subscribed to the
 Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to
 algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
  
   --

   You received this message because you are subscribed to the
 Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com
 .
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
   --

   You received this message because you are subscribed to the
 Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
 
  --

  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
  --

  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send 

Re: [algogeeks] amazon test question!!!

2011-08-08 Thread shady
   a
   / \
/   \
 b  c
   /   \   /\
d  e   fg

for the given tree, the ans depends on the way one has implemented delete
function as correctly mentioned by sagar if it only deletes and doesnt
care of returning null to c-right after deleting g then the answer will be
3, and if it delete is properly implemented then it deletes as
g, f, c, e, d, b, a



On Tue, Aug 9, 2011 at 12:08 AM, aditi garg aditi.garg.6...@gmail.comwrote:

 when f and g have been deleted wudnt the last condition left==null
 right==null be satisfied fr c as well?


 On Tue, Aug 9, 2011 at 12:01 AM, sagar pareek sagarpar...@gmail.comwrote:

 Option 3 is correct :-

 suppose we have tree

a
/ \
 /   \
  b  c
/   \   /\
 d  e   fg

 now it will first delete g
 then it will delete f
  now why would it delete c ?
 we are deleting f and g because both left and right are NULL of f and g

 but still c-left and c-right has address of f and g respectively
 (dangling pointer ) but if we check the condition
 (c-left==NULLc-right==NULL) , it will not satisfy hence c will not be
 deleted...

 so we  we have to do c-left=NULL and c-right=NULL before deleting

 pls correct me if i m wrong



 On Mon, Aug 8, 2011 at 11:23 PM, *$* gopi.komand...@gmail.com wrote:

 I guess option 1 is correct

 Thx,
 --Gopi


 On Mon, Aug 8, 2011 at 11:07 PM, siddharam suresh 
 siddharam@gmail.com wrote:

 func( Node *node){

 if( node-left == NULL  node-right == NULL )

 delete(node);

 if(node-right != NULL)

   func( node-right);

  if(node-left != NULL)

func( node-left);


 }

 for this code option 3 is correct

 Thank you,
  Siddharam



 On Mon, Aug 8, 2011 at 11:03 PM, rajul jain rajuljain...@gmail.comwrote:

 This is what i am trying to say to debabrata


 On Mon, Aug 8, 2011 at 10:56 PM, aditi garg aditi.garg.6...@gmail.com
  wrote:

 @debrata : bt remember its a recursive function...once the leaf node
 gets deleted thn it will move bak to the node and thn to the left of it
 fr eg
   a
/\
   b c
 /  \/  \
d   e  f   g
 frst g will be deleted...then f thn it wil delete c and so on...i
 think the ans shud be 1...correct me if i am wrong...
 On Mon, Aug 8, 2011 at 10:49 PM, Debabrata Das 
 debabrata.barunhal...@gmail.com wrote:

 check this condition
 if( node-left == NULL  node-right == NULL )
 it is true only for leaves node

 On Mon, Aug 8, 2011 at 10:46 PM, rajul jain rajuljain...@gmail.com
 wrote:
  I have also made same answer on first look but read 3rd  option
 correctly it
  say deletion of leaves from right to left not internal nodes.
 
  On Mon, Aug 8, 2011 at 10:36 PM, Debabrata Das
  debabrata.barunhal...@gmail.com wrote:
 
  i think 3
 
  On Mon, Aug 8, 2011 at 10:32 PM, rajul jain 
 rajuljain...@gmail.com
  wrote:
   got it thanks
  
   On Mon, Aug 8, 2011 at 10:30 PM, Akash Mukherjee 
 akash...@gmail.com
   wrote:
  
   i think its 1 though ...
  
   On Mon, Aug 8, 2011 at 10:21 PM, rohit rajuljain...@gmail.com
 wrote:
  
   What will the following code snippet do, when is it passed the
 root of
   a binary tree ?
   func( Node *node){
  
if(node-right != NULL)
  
 func( node-right);
  
if(node-left != NULL)
  
  func( node-left);
  
if( node-left == NULL  node-right == NULL )
  
   delete(node);
  
   }
  
   Pick choice
   Delete the tree from bottom to top
  
   Delete the tree from top to bottom
  
   Delete the leaf nodes from right to left
  
   Delete the leaf nodes from left to right
  
   I think it is 3
  
   --

   You received this message because you are subscribed to the
 Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to
 algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
  
   --

   You received this message because you are subscribed to the
 Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to
 algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
   --

   You received this message because you are subscribed to the
 Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com
 .
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this