Order of Binary_Search Inbuilt Function?

Choose the correct output and time complexity for the following code :

list< int > myList = { 2, 6, 12, 13, 15, 18, 20};
cout << binary_search(myList.begin(), myList.end(), 20) ;

  1. Output is 20 and time complexity is Linear in size of the list.

  2. Output is 1 and time complexity is Linear in size of the list.

  3. Output is 20 and time complexity is Logarithmic in size of the list.

  4. Output is 1 and time complexity is Logarithmic in size of the list.

In the video, sir said that the order is logN , however here the answer is linear. What is the correct answer?

binary search on Linked_list is linear
but on array it is logn

because in linked list to find mid
we have to traverse the list so it is linear

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.