Correct option is B
Binary Search works by repeatedly dividing a sorted array or list in half and comparing the target value to the middle element. This results in a logarithmic time complexity of O(log n) in the worst case.
Important Key Points:
1. Binary Search is efficient when dealing with sorted arrays or lists.
2. The search space is halved after each comparison, which results in O(log n) time complexity in the worst case.
3. Binary search is ideal for scenarios where data is organized in a way that allows for this divide and conquer approach.
4. The logarithmic time complexity makes binary search far more efficient than linear search for large datasets.
Knowledge Booster:
· Linear Search (O(n)): Scans each element in the list one by one, making it less efficient with a time complexity of O(n) in the worst case.
· Depth First Search (O(V + E)): Used for graph traversal and not relevant for array searches.
· Breadth First Search (O(V + E)): Also used for graph traversal, and it doesn't have O(log n) time complexity.
· Exponential Search (O(log n)): While exponential search is related to binary search, its time complexity can vary depending on the scenario, but it’s typically used for unbounded arrays.