Aryan's blog

By Aryan, history, 7 years ago, In English

I really want to know whats the difference between 2 types of lower_bound? 1) lower_bound(st.begin(), st.end(), val) and 2) st.lower_bound(val). As you can see in 28778333 and 28778499 the second type is much much faster!

  • Vote: I like it
  • -11
  • Vote: I do not like it

»
7 years ago, # |
  Vote: I like it +10 Vote: I do not like it

If you have something like std::set(no random access iterators), set.lower_bound works in o(logN) and lower_bound(st,begin(), st.end()) works in O(n), checking every element, where N is the size of set