On Sep 1, 8:02 pm, Ramaswamy R <ramaswam...@gmail.com> wrote:
> Brute force, pick all combinations and keep track of minimum difference.
> Complexity: O(n^2) - (n-1)+(n-2)+(n-3) ... 1
> A little better, use any of the O(nlog n) sorting algorithm. In O(n) compare
> adjacent pairs and find the minimum difference. Complexity O(nlog n).
>

Could modify the sort to keep track of the minimum distance during
comparison, if two numbers have the minimum distance the sort must
compare them at some point.

--
Geoff
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@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
-~----------~----~----~----~------~----~------~--~---

Reply via email to