we are using binary search, so time complexity should be logarithmic.
Answer of 2nd mcq
but the answer is saying it is taking linear time to search last element 20
in this question, the answer given is option B, my question is how the time complexity in using binary_search is linear??
@manikNFt @amankumarkeshu
sorry to interrupt u guys
actually it should be O(n) only, because we are applying binary search on linked list .
everytime we need to find n/2th by traversing half of the list .
as per recurrence relatation t(n)=t(n/2)+O(n) = O(2*n)=O(n) .
that why it is giving b as correct output
Ohk, that’s a new thing i learnt today.
Thanks
@aman212yadav Thank you so much for showing me the error. I actually didn’t see the list in the question. And your answer is totally correct. The time complexity will be 0(n)
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.
