, O (log n)
, O (n) . , .
The idea of making the values in order in order takes O (n * log (n)), if you don't do it again and again and cache the result, why bother? just use linear search.
(note that you are interested in finding a value, not a key)
source
share