In order traversal results in a sorted list of elements of BST say 
[a,b,c,d,e]. make another array containing [k-a,k-b,k-c,k-d,k-e].Reverse 
yeilds [k-e,k-d,k-c,k-b,k-a]. Now apply the standard merge function (Merge 
sort). on [a,b,c,d,e] & [k-e,k-d,k-c,k-b,k-a]. Finally adjacent equal 
entries represent a valid pair. U can see that each valid pair will be 
repeated twice (select only one). In case in the BST there is an entry k/2 
then you must find its duplicate by a linear time search to find its 
correctness.

:)

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/C1MPFDKg1P8J.
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