The following snippet is returning me 0. I expected it to be 1. What\'s wrong going on here?
#include
#include
#include
I ran the program and saw this:
11
22
10
20
30
40
50
Binary Search - 0
Your array is not sorted, therefore, binary search fails. (it sees 11
in the first position, and concludes 10
does not exist here)
You either want to ensure the array is sorted before binary searching or use the regular std::find
.