step1>construct heap using siftdown. // time complexity wil be O(n) and
space complexity O(1).
step2>take mindifference=a[1].
step3>for i=1 ,i<=n/2 do
{ find the difference of (root,root-left),(root,root->right)and
(root->left,root->right).and maintain mindifference is the smallest
difference of among
three differences.
}
step4>return mindifference.
plz correct me if im wrong....
--
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.