2 ms·
It is, but so is storing a sorted array.
by contravariant 4y ago
It is, but so is storing a sorted array.
- account42 4y agoIt's still misleading to call this a binary search when that is commonly understood as an algorithm operating on a sorted range which is not just an arbitrary datastructure but something that already exists in many situations. If you just need fast lower_bound lookup for a set that you control and which has no other uses then sure this is nice, but more commonly you only care if an element is in the set and in that case if you can control the data structure then there are many more options.
- eska 4y agoI agree with you. Algorithms don’t exist in a bubble, but are always accompanied with a data structure. A heap sorted array is different from a linearly sorted array. Binary search is only defined for the latter.