Skip to main content

Binary search for 89; hash functions

Short answer

Compare with middle: mid=6 (50) → low=7; mid=9 (85) → low=10; mid=11 (94) → high=10; mid=10 (89) → found at index 10 after 4 steps.

Use binary search to find 89 from the data: 8, 12, 20, 24, 30, 45, 50, 68, 72, 85, 89, 94, 98.

Data (index 0 to 12): 8, 12, 20, 24, 30, 45, 50, 68, 72, 85, 89, 94, 98. Key = 89.

Steplowhighmida[mid]Decision
101265089 > 50, so low = 7
271298589 > 85, so low = 10
31012119489 < 94, so high = 10
410101089equal, found

Answer: 89 is found at index 10 (11th position) after 4 steps. (mid = ⌊(low + high)/2⌋ at each step.)

✓ Answer checked by Claude Opus 5.5 (high effort)

All Data Structure and Algorithm chapter 8 questions →