To achieve O(logn) search time, you have to maintain a vector that is sorted, and then you can use standard functions which implement binary searching (binary_search, lower_bound, upper_bound, and equal_range). A vector’s iterators being random access allow binary searching to occur in logn time.

]]>i heard somewhere that vectors are very quick to search with time O(log(n)). however the diagrams from this article feels to me contradicts this.

when searching through the vector using iterators, does it search through linearly? i thought that vectors had “random access”.

hope my question makes sense.

]]>