How to include binary search in Sorted Linked List

Need a code which will insert a new element in the Sorted Linked List using Binary Search.The code must be only in C++ please
Last edited on
The std::lower_bound sounds like a binary search.
http://www.cplusplus.com/reference/algorithm/lower_bound/
> Sorted Linked List using Binary Search.

O( log N ) binary search requires a sequence that provides random access in constant time.

std::lower_bound() is O(N) (it does a linear search) if the iterator is not a RandomAccessIterator.
Topic archived. No new replies allowed.