My approach :
Have a pointer to the start (smallest of the array) of each of the N
arrays.
Until all pointers reach end of respective arrays :
take the smallest value from all of the pointers
and compute the difference between the smallest and the current pointers
of each of the arrays
let newdiff be the smallest among all the diffs
if newdiff < olddiff :
olddiff = newdiff
only advance the smallest number pointer
Correctness :
I believe that if the smallest difference occurs between a and b ,(a is
smallest) you will come across that comparison and find the least.
Complexity : 0(kn) , it should be the best because you atleast need to read
all of the input.
Please correct me if i'm wrong.
On Mon, May 9, 2011 at 8:55 PM, bittu <[email protected]> wrote:
> see here & let me know if anything wrong..??
>
>
> http://shashank7s.blogspot.com/2011/05/wap-to-find-minimum-difference-between.html
>
>
>
> Thanks & Regrads
> Shashank >> " the Best Way to Escape From The problem is to Solve it"
> Computer Science & Engg.
> BIT Mesra
>
> --
> 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.
>
>
--
regards,
chinna.
--
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.