Sir in question 2 binary search takes log(n) time then how come answer is linear search.
Doubt in question 2
Hey @adityamehrotra275 can you paste the question here? so that i can see why is it soo. As i don’t have access to this quiz.
If the question is this:
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.
Then answer will be option 2 as myList is not an array, it’s a linked list. If you are not familiar with linked list then there will be a section of linked list in your course. When you will do that you will be able to find out why is it option 2.
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.