Trace binary search indices in 18-element array

Quick Overview

This question evaluates understanding of the binary search algorithm, integer mid-index computation, and array indexing nuances (1-based indexing) when tracing the sequence of probed indices.

Trace binary search indices in 18-element array

Company: Bitkernel

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Online Assessment

An ordered list of 18 elements is stored in a one-dimensional array `A[1..18]` (1-based indexing). You perform standard binary search for the element at position `A[3]`. Assuming that at each step the middle index is computed as `mid = floor((low + high) / 2)`, what is the sequence of indices examined during the search for `A[3]`? Options: - A. `1, 2, 3` - B. `9, 5, 3` - C. `9, 5, 2, 3` - D. `9, 4, 2, 3`

Quick Answer: This question evaluates understanding of the binary search algorithm, integer mid-index computation, and array indexing nuances (1-based indexing) when tracing the sequence of probed indices.

|Home/Software Engineering Fundamentals/Bitkernel
Bitkernel logo
Bitkernel
Oct 24, 2025
mediumSoftware EngineerOnline AssessmentSoftware Engineering Fundamentals
2
0

An ordered list of 18 elements is stored in a one-dimensional array A[1..18] (1-based indexing). You perform standard binary search for the element at position A[3].

Assuming that at each step the middle index is computed as mid = floor((low + high) / 2), what is the sequence of indices examined during the search for A[3]?

Options:

  • A. 1, 2, 3
  • B. 9, 5, 3
  • C. 9, 5, 2, 3
  • D. 9, 4, 2, 3
Loading comments...