[algogeeks] Algorithm intensive Please solve

2010-02-12 Thread GentLeBoY
given 2N points in a plane. Pair up to obtain N distinct pairs such
that total sum of paired distances is minimum.
N can be atmost 50.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@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] Re: Merge two BST in O(n) time with O(1)

2010-02-12 Thread Algoose Chase
Hi,

@Asish meena  and Arun :
   I dont think you can simply append a whole tree( BST2) at some
position just because the root of the BST2 is at its correct position.For
instance ,  Lets say you append BST2's Root anywhere within the left subtree
of BST1's Root. But if the right most leaf node of BST2 is greater than the
root of BST1, then the merged tree is no longer a binary search tree. Hence
your approach will not work in all cases.


On Wed, Feb 10, 2010 at 5:12 PM, r_arun rathakrishnana...@gmail.com wrote:

 Your algorithm is correct. But

  3. Remove the children from this place and store them as BST3 and BST4.

 This is not required , because trying to merge BST2 with BST1,which is
 equivalent to finding a place to insert a pointer to root of BST2 in
 BST1. Whenever you need a place for a new node, you take a place of a
 existing leaf in BST1 for that new node. So we need not worry about
 children.

 Also in a BST there is no configuration for which a new element can
 not be inserted.

 So we can just link the pointers and get a merged tree.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@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.