---
title: "Binary search for 89; hash functions"
subject: "Data Structure and Algorithm"
chapter: 8
key: "semester_4/data_structure_and_algorithm:binary-search-89-hashing"
source: https://www.bctengineer.com/q/semester_4/data_structure_and_algorithm/binary-search-89-hashing
site: BCT Engineering
---

# Binary search for 89; hash functions

Data Structure and Algorithm · Chapter 8: Searching

- Asked in: 2068 Bhadra, 3 marks
- Video: [Binary Search examples | Successful Search | DAA | Lec-13 | Bhanu Priya](https://www.youtube.com/watch?v=81QLBCW94Oo) — Education 4u
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_4/data_structure_and_algorithm/binary-search-89-hashing
- Whole chapter: https://www.bctengineer.com/md/semester_4/data_structure_and_algorithm/chapter-8

## Question

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

## 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.

## Answer

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

| Step | low | high | mid | a[mid] | Decision |
|---|---|---|---|---|---|
| 1 | 0 | 12 | 6 | 50 | 89 > 50, so low = 7 |
| 2 | 7 | 12 | 9 | 85 | 89 > 85, so low = 10 |
| 3 | 10 | 12 | 11 | 94 | 89 < 94, so high = 10 |
| 4 | 10 | 10 | 10 | 89 | equal, found |

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

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. With 13 elements, index 0 to 12, what is the first mid?
   A. 5
   B. 6
   C. 7
   D. 12
   Answer: B. (0+12)/2 = 6, a[6] = 50. (Key point: First mid)

2. After 89 > 85 at mid 9, what changes?
   A. low = 10
   B. high = 8
   C. low = 9
   D. high = 10
   Answer: A. Search right of mid. (Key point: Move)

3. Where is 89 found?
   A. Index 10 after 4 steps
   B. Index 11 after 3 steps
   C. Index 9 after 2 steps
   D. Not found
   Answer: A. Index 10 matches at step 4. (Key point: Result)

## Related in Data Structure and Algorithm

- [AVL tree for 10 20 30 50 45 40 8 5 3](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Aavl-build-10-20-30) — Data Structure and Algorithm, chapter 6
- [Binary search for 54 in sorted data](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Abinary-search-54) — Data Structure and Algorithm, chapter 8
- [Hashing and different hash functions](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Ahashing-hash-functions) — Data Structure and Algorithm, chapter 8
- [AVL tree for 52, 65, 72, 15, 11, 32, 20](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Aavl-build-52-65-72) — Data Structure and Algorithm, chapter 6
- [Binary search with algorithm and example](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Abinary-search-algorithm-example) — Data Structure and Algorithm, chapter 8, asked 4×
- [Complexity of binary search](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Abinary-search-complexity) — Data Structure and Algorithm, chapter 8

## Related in other subjects

- [Theodolite traverse ABCDA with missing VCR (68°30′10″)](https://www.bctengineer.com/question.md?key=semester_3%2Fsurveying_i%3Atheodolite-traverse-abcda-hcr-vcr-68-30-10) — Surveying I, chapter 7
- [Subnet 202.77.19.0/24 for 30, 24, 25, 20](https://www.bctengineer.com/question.md?key=semester_7%2Fcomputer_networks_and_security%3Asubnetting-202-77-19) — Computer Networks and Security, chapter 4
- [Volume from central depths 1.85, 2.15, 2.45](https://www.bctengineer.com/question.md?key=semester_3%2Fsurveying_i%3Avolume-central-depths-1-85-2-15-2-45) — Surveying I, chapter 9
- [Round robin scheduling (53, 17, 68, 24 ms)](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3Asched-rr-53-17-68-24-q4) — Embedded System, chapter 6, asked 4×
