The time coplexity for logarithmic search is O(log(n) ) then why the answer is linear time complexity?
Doubt in Question 2 Solution
Please copy and paste the question here.
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) ; (a) Output is 20 and time complexity is Linear in size of the list. (b) 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. (d) Output is 1 and time complexity is Logarithmic in size of the list
my answer was (d) but it says correct answer is (b)
Yes it should be d. You are correct.Carry on, I will report it further.
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.