I wanted to ask how lower_bound in cpp ( C++ ) behaves when it is applied on unsorted array. I mean when I ran the following program.
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
int arr[]={8,9,10,1,2,3};
auto itr= lower_bound(arr,arr+6,7);
cout<<*itr<<endl;
}
it gave the output as '2'. But according to definition of lower_bound, it gives the iterator to first element which fails '<' with 'val'. So according to this definition, shouldn't the answer be '8', because "8 is not less than 7". I know it works on sorted array, but I want to know whether or not, there is a logic behind this value or is it a junk.
Thanks.