If their is no constrain on assumptions.

1.Sort the array.
2. check the dif between 2 elements.

{ 99,35,45,33,88,9098,112,33455,678,3}

sorted arrary : { } would be something.
now update the min_diff.

another example : { 7,8,1,3,5,4}
sorted arrary  : { 1,3,4,5,7,8}
min diff is 1.

Please correct me if i missed something.

On Mon, Sep 27, 2010 at 1:13 PM, satish <satish....@gmail.com> wrote:

> 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 algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com<algogeeks%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.

Reply via email to