Q2. of algoithm stl QUIZ

it is showing time complexity as linear…shouldnt int be logarithmic?

@manthan.joshi.jiit share the question here

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.

@manthan.joshi.jiit it will be linear as mid point calculation in list when doing binary search takes o(n) time
hope its clear if yes dont forget to hit like and mark resolved :smiley: