in reply to Searching parallel arrays.
Idea 1:
Use a modified merge algorithm to efficiently copy all values into a single sorted array. In doing so, create a parallel hash that knows which array the value came from. Walking the sorted array to find spans of 4 should be straight forward. I believe this is a refinement jbert's idea.
Idea 2:
This is more memory friendlier but will likely be slower. Use a binary search with a modified merge algorithm. You will need to keep track track of your position in each array. This will keep track of a moving end point of your binary search as well as allow you to walk your arrays as a merge algorithm would. Find the lowest value using the current positions, do a binary search over each array looking for the next value. I think you can work out from here the rest of the details.
Cheers - L~R
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Searching parallel arrays.
by BrowserUk (Patriarch) on Dec 08, 2006 at 21:50 UTC | |
by Limbic~Region (Chancellor) on Dec 09, 2006 at 00:32 UTC | |
by BrowserUk (Patriarch) on Dec 09, 2006 at 02:12 UTC | |
by Limbic~Region (Chancellor) on Dec 09, 2006 at 02:42 UTC | |
by Not_a_Number (Prior) on Dec 09, 2006 at 19:29 UTC | |
by BrowserUk (Patriarch) on Dec 09, 2006 at 22:20 UTC |