-
January 14th, 2009, 03:27 AM
#1
minimal distance between numbers in one dimentional array
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
-
January 14th, 2009, 04:26 AM
#2
Re: minimal distance between numbers in one dimentional array
Yes, there is O(n) algo to solve it.
-
January 14th, 2009, 06:42 AM
#3
Re: minimal distance between numbers in one dimentional array
Originally Posted by Thu
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
-
January 14th, 2009, 12:20 PM
#4
Re: minimal distance between numbers in one dimentional array
Well, one approach would be to use Radix sort and then find the answer in a single pass over the sorted array.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|