Answer should be 4 because binary search takes logn time to search

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) ;

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

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

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

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

hey, did u notice that the data is given as a list and not an array, and unlike an array a list cannot be directly accessed anywhere but has to be accessed linearly element by element, which is why the time complexity is linear. related documentation