I am looking for a custom binary search, not STL. How can we do the custom binary search on set? asked 08 Jun '18, 14:31
showing 5 of 6
show all

You are not logged in. Please login at www.codechef.com to post your questions!
×CodeChef Discussion 
I am looking for a custom binary search, not STL. How can we do the custom binary search on set? asked 08 Jun '18, 14:31
showing 5 of 6
show all

Once you sign in you will be able to subscribe for any updates here
By RSS:Markdown Basics
Question tags:
question asked: 08 Jun '18, 14:31
question was seen: 172 times
last updated: 09 Jun '18, 10:11
I have got a good website which can answer this question very appropriately. Please refer here , and then here
First I tried google after that I have posted this question here because I didn't get anything relevant. I also tried binary search on set using std:: advance but std:: advance takes O(n) time in worst case on set.
Its been asked in the forums. I remember giving a link to that in one of my editorials. lower_bound is the function you are looking for. Just be careful on which lowerbound. There are 2 versions, one is $O(N)$ other $O(LogN)$
I know about lower_bound and upper_bound. I have used them many times. Here I have work which can be done using binary_search. And I am not sure if we can do binary search on set like we do a normal binary_search without c++ STL.
Then thats the case of question being vague. Mention that you are looking for a custom binary search function and not STL ones like lower_bound. The only thing you asked is "Can we do binary search? If yes how?" the answer to which is STL lower_bound.
One of the reasons I dont favor one liner questions.
I have edited the question. thanks