In some cases, we just want to if an element exists in a sorted list, then we can use the STL function:
To use this function, you must include the header
Note before we use
binary_search(), the list must be sorted, either in ascending order or in descending order.
Here is a simpler example explaining how to use this function.
1 2 3 4 5 6 7 8 9 10 11 12