mat65
January 14th, 2009, 03:27 AM
I there an O(n) algorithm for finding minimal distance between numbers in an one dimensional array? Does it matter if all the numbers are positive or negative? The array is not sorted
|
Click to See Complete Forum and Search --> : minimal distance between numbers in one dimentional array mat65 January 14th, 2009, 03:27 AM I there an O(n) algorithm for finding minimal distance between numbers in an one dimensional array? Does it matter if all the numbers are positive or negative? The array is not sorted Thu January 14th, 2009, 04:26 AM Yes, there is O(n) algo to solve it. mat65 January 14th, 2009, 06:42 AM Yes, there is O(n) algo to solve it. does it work anyway or it depends if the numbers are positive or negative? can you describe the algo? thanks Lindley January 14th, 2009, 12:20 PM Well, one approach would be to use Radix sort and then find the answer in a single pass over the sorted array. codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |