diff options
author | Mattias Andrée <maandree@kth.se> | 2020-06-11 18:29:01 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2020-06-11 18:41:35 +0200 |
commit | 438208bafad929f34d837e8f23f121d0bbe02e9a (patch) | |
tree | 083e9441b6b01c1f29333ce5c4104c5098790808 /README | |
download | binary-multisearch.h-438208bafad929f34d837e8f23f121d0bbe02e9a.tar.gz binary-multisearch.h-438208bafad929f34d837e8f23f121d0bbe02e9a.tar.bz2 binary-multisearch.h-438208bafad929f34d837e8f23f121d0bbe02e9a.tar.xz |
First commit
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'README')
-rw-r--r-- | README | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -0,0 +1,24 @@ +Binary multisearch + +Description: + Given a sorted list of unique items, find their in another + list sorted list their position or if missing where they + ought to be inserted. Both list must allow random access. + +Complexity: + n = number of elements in target list + m = number of element to locate + + Time complexity: O(S(n) + m) + S = time complexity function of underlaying search algorithm, + e.g. S(n) = O(log n) in average case for binary search given O(1) comparison. + + Auxiliary space complexity: + List return version: O(m) + Online version: O(log m) + +Notes: + In online version, positions for elements are returned in + arbitrary (deterministic) order, rather than sequential. + +I wrote this algorithm back in Feburary 2013. |