sir answer for binary search must be o(logn) . here it is given as linear complexity.
Quiz question no. 2
hello @Kshubham1532
its time complexity will be O(n)
reason->
list stl is like linked list i.e we cannot ranomly access any element . if we want to access any element then we need to traverse from start of the list to reach that particular node.
Now because we are applying binary search on list.
getting mid element will be O(n) // o(n) because to get mid element we need to traverse half of the list .
so the recurrence relation for this problem will be
T(N)=T(N/2) + O(n)
on solving this relation u will get
T(n)=O(n)
instead of list if we use array or vector there what should we get?
then time complexity will be O(log(N) )
okay thanks! should we need to remember this?
No,you can derive it.