0%
0 / 14 answered
Binary Search Practice Test
•14 QuestionsQuestion
1 / 14
Q1
A student uses iterative binary search on sorted array 5, 8, 12, 17, 21, 26, 30, 34, 41, 49, 55, 63, 70, 81 to find target 34; midpoint is $\lfloor(\text{low}+\text{high})/2\rfloor$. Steps: low=0, high=13, mid=6 (30)<34 so low=7; next mid=$\lfloor(7+13)/2\rfloor$=10 (55)>34 so high=9; next mid=$\lfloor(7+9)/2\rfloor$=8 (41)>34 so high=7; next mid=$\lfloor(7+7)/2\rfloor$=7 (34) found. Refer to the array provided above. How many iterations are required to locate the target element using binary search?
A student uses iterative binary search on sorted array 5, 8, 12, 17, 21, 26, 30, 34, 41, 49, 55, 63, 70, 81 to find target 34; midpoint is $\lfloor(\text{low}+\text{high})/2\rfloor$. Steps: low=0, high=13, mid=6 (30)<34 so low=7; next mid=$\lfloor(7+13)/2\rfloor$=10 (55)>34 so high=9; next mid=$\lfloor(7+9)/2\rfloor$=8 (41)>34 so high=7; next mid=$\lfloor(7+7)/2\rfloor$=7 (34) found. Refer to the array provided above. How many iterations are required to locate the target element using binary search?