. What is the time complexity of binary search with iteration

A: O(nlogn)

B: O(logn)

C: O(n)

D: O(n2)


Best Answer


The "Divide and Conquer" principle governs the binary search algorithm. Binary Search, like all divide and conquer algorithms,

divides a huge array into smaller sub-arrays before solving recursively (or iteratively).

The data collection must be in the "sorted" format for this technique to perform effectively.

Binary search has a substantially lower temporal complexity of "O(log n)" due to its gradually dividing approach.

Final Answer:

Hence, correct option is B i.e., O(logn).


Talk to Our counsellor