in reply to Re: Modified Binary Search
in thread Modified Binary Search
If he needs the number of different(!) elements, there would be a tremendous speed-up but the hash would be superfluous.
If he needs number of elements, he would have to sum up all different elements between $beg and $end instead of just subtracting $beg from $end. Depending on the data set this additional step could eat away any savings from performing a few steps more in the binary search.
To be precise: It must be 2*log2(average number of duplicates) > (average number of different elements in a search) to get a speed-up.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Modified Binary Search
by BrowserUk (Patriarch) on Jan 14, 2010 at 11:03 UTC | |
by JavaFan (Canon) on Jan 14, 2010 at 11:21 UTC | |
by BrowserUk (Patriarch) on Jan 14, 2010 at 11:55 UTC | |
by salva (Canon) on Jan 14, 2010 at 13:37 UTC | |
by JavaFan (Canon) on Jan 14, 2010 at 13:03 UTC | |
by BrowserUk (Patriarch) on Jan 14, 2010 at 13:06 UTC | |
| |
by Anonymous Monk on Aug 11, 2011 at 15:30 UTC | |
by jethro (Monsignor) on Jan 14, 2010 at 14:42 UTC | |
by Limbic~Region (Chancellor) on Jan 14, 2010 at 15:39 UTC |