set<int> s;
s.insert(1);
s.insert(2);
...
s.insert(n);
Run Code Online (Sandbox Code Playgroud)
我想知道从1..n开始的数字s.find(k)在哪里需要多长时间k?我假设它是log(n).这是对的吗?
Dav*_*eas 17
O(log N)搜索单个元素.
§23.1.2表69
expression return note complexity
a.find(k) iterator; returns an iterator pointing to an logarithmic
const_iterator element with the key equivalent to k,
for constant a or a.end() if such an element is not
found
Run Code Online (Sandbox Code Playgroud)