S
solandre
hi there,
i have to find matches in two sorted arrays. there are two good
possibilities as a temporary solution, performing different, depending
on the inner structure of the data. but i try to find a better one.
..possibility one ...
...is running through the arrays in a zig-zag, always taking the an
element from array A and searching the remaining elements of array B
sequentially for an equal or a higher match.
...if i find an equal i iterate in both arrays, ...
...if i find a higher, i flip sides take the found element from array B
and search array A from the position where the last element from array
A was taken +1 sequentially for an equal or a higher.
...this is called "Merged join", i read.
...it performs well if the matching elements are "close" together.
..possibility two...
...i enhanced this method with binarysearch, as the arrays are several
10 million elements big.
...binarysearch is used instead of sequentially searching the remainder
of an array.
...this performs better if the matching elements are far appart, but
incredibly poor, if the matches are close together.
any suggestions for a still faster solution to find matches in two
sorted arrays?
thanks
i have to find matches in two sorted arrays. there are two good
possibilities as a temporary solution, performing different, depending
on the inner structure of the data. but i try to find a better one.
..possibility one ...
...is running through the arrays in a zig-zag, always taking the an
element from array A and searching the remaining elements of array B
sequentially for an equal or a higher match.
...if i find an equal i iterate in both arrays, ...
...if i find a higher, i flip sides take the found element from array B
and search array A from the position where the last element from array
A was taken +1 sequentially for an equal or a higher.
...this is called "Merged join", i read.
...it performs well if the matching elements are "close" together.
..possibility two...
...i enhanced this method with binarysearch, as the arrays are several
10 million elements big.
...binarysearch is used instead of sequentially searching the remainder
of an array.
...this performs better if the matching elements are far appart, but
incredibly poor, if the matches are close together.
any suggestions for a still faster solution to find matches in two
sorted arrays?
thanks