Question:medium

Assume a list = [2, 4, 6, 8, 10, 12, 14]
How many comparisons are required to find element '4' in the list using Binary search?

Show Hint

Always perform integer division (floor division) when calculating mid:
\[ \text{mid} = (\text{low} + \text{high}) // 2 \]
Keep a clear track of the comparison count at each step of the loop!
Updated On: Jun 11, 2026
  • 3
  • 4
  • 2
  • 1
Show Solution

The Correct Option is C

Solution and Explanation


Step 1: Understanding the Question:

The question asks to find the exact number of key comparisons required to locate the element 4 within the sorted list [2, 4, 6, 8, 10, 12, 14] using the Binary Search algorithm.

Step 2: Binary Search Logic:

- Binary search operates on a sorted array by repeatedly dividing the search interval in half.
- Let low represent the start index and high represent the end index.
- In each step, we calculate the middle index:
\[ \text{mid} = \lfloor \frac{\text{low} + \text{high}}{2} \rfloor \]
- We then compare the element at mid with the target element.

Step 3: Step-by-Step Execution Trace:

- Given list: [2, 4, 6, 8, 10, 12, 14]
- Target element = 4
- Indices of list: 0, 1, 2, 3, 4, 5, 6 (total elements, $n = 7$)
- Iteration 1:
- Initial pointers: $\text{low} = 0$, $\text{high} = 6$.
- Calculate middle index:
\[ \text{mid} = \lfloor \frac{0 + 6}{2} \rfloor = 3 \]
- Compare element at index 3 (list[3] which is 8) with target (4):
- Comparison 1: Is 8 == 4? No.
- Since {4 < 8}, the search space is restricted to the left half.
- New pointers: $\text{low} = 0$, $\text{high} = \text{mid} - 1 = 2$.
- Iteration 2:
- Current pointers: $\text{low} = 0$, $\text{high} = 2$.
- Calculate middle index:
\[ \text{mid} = \lfloor \frac{0 + 2}{2} \rfloor = 1 \]
- Compare element at index 1 (list[1] which is 4) with target (4):
- Comparison 2: Is 4 == 4? Yes.
- The target is found at index 1. The search terminates successfully.
- Thus, the total number of comparisons made is exactly 2.

Step 4: Final Answer:

The Binary Search algorithm makes 2 comparisons to locate the element '4'.
Hence, option (C) is the correct choice.
Was this answer helpful?
0


Questions Asked in CUET (UG) exam