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) ;
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) ;
Yes answer must be O(N), because the data structure here used is Linked list not array, in array we can access any index element in O(1) time, but for accessing ith element in Linked list it is O(i), and i will be n in worst case so it is O(N).
Hope it helps.
it is just a vector ? like array ???
how it is a link list 
Carefully see the syntax, it is:-
list< int > myList = { 2, 6, 12, 13, 15, 18, 20}
ohh got that ! thanks 
sir apart from this question one general doubt ---->
Could anyone tell me that…
The challenges problem would be active even after the session is expired
But the problems in between like in stl they will go away ? Or be there ???
Not the challenges one
But the one in between
In algo++
@hg11110000 The problems will remain available after that also.
Mark this doubt as resolved if you don’t have any furthur query.
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.