in reply to Code efficiency / algorithm
IIRC, you can build a segment tree in O (n log2 n) time, while queries take O (log2 n + k) time. So, if you have N entries in datafile1 and M entries in datafile2, your total running time would be O ((N + M) log2 N + K), where K is the number of matches. It might be that it's actually a factor of O (log N) less. This surely beats the O (N * M) approach of trying to match everything with everything.
Unfortunally, I don't think there's a module available that implements segment trees.
Abigail
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Code efficiency / algorithm
by BrowserUk (Patriarch) on Jan 14, 2003 at 11:15 UTC | |
by Abigail-II (Bishop) on Jan 14, 2003 at 11:23 UTC | |
|
Re: Re: Code efficiency / algorithm
by dws (Chancellor) on Jan 14, 2003 at 21:53 UTC | |
by tall_man (Parson) on Jan 15, 2003 at 01:37 UTC | |
|
Re: Re: Code efficiency / algorithm
by dave8775 (Novice) on Jan 14, 2003 at 16:06 UTC | |
by Abigail-II (Bishop) on Jan 14, 2003 at 16:38 UTC | |
by tall_man (Parson) on Jan 14, 2003 at 16:51 UTC |