If the array is [1, 2, 3, 4, 5] and the target is 3, what will be the mid index during the first iteration of binary search?

Practice Questions

1 question
Q1
If the array is [1, 2, 3, 4, 5] and the target is 3, what will be the mid index during the first iteration of binary search?
  1. 0
  2. 1
  3. 2
  4. 3

Questions & Step-by-step Solutions

1 item
Q
Q: If the array is [1, 2, 3, 4, 5] and the target is 3, what will be the mid index during the first iteration of binary search?
Solution: In the first iteration, mid is calculated as (0 + 4) // 2 = 2, which corresponds to the value 3.
Steps: 5

Related Questions

Soulshift Feedback ×

On a scale of 0–10, how likely are you to recommend The Soulshift Academy?

Not likely Very likely