6) G-ven the following ordered array: (5 pts each) 4 36 17] 67 68 71 83 85 [10]
ID: 3911064 • Letter: 6
Question
6) G-ven the following ordered array: (5 pts each) 4 36 17] 67 68 71 83 85 [10] [12] [13] [14] [15] 90 94 a) Using the binary search algorithm to search for the target value 88 For each pass, list the high and low index, and the calculated middle index Finally, state what causes the search to stop, and the result of the search b) Using the binary search algorithm to search for the target value 60 For each pass, list the high and low index, and the calculated middle index Finally, state what causes the search to stop, and the result of the searchExplanation / Answer
a)...searching value 88
---------------------------------
Low : 0, High : 15, Middle : 7
Search num :88, current mid element :67
67 is less than 88
---------------------------------
---------------------------------
Low : 8, High : 15, Middle : 11
Search num :88, current mid element :85
85 is less than 88
---------------------------------
---------------------------------
Low : 12, High : 15, Middle : 13
Search num :88, current mid element :90
90 is greater than 88
---------------------------------
---------------------------------
Low : 12, High : 12, Middle : 12
Search num :88, current mid element :88
Since both are equal stops here...and 88 found at index :12
---------------------------------
b)...searching value 60
---------------------------------
Low : 0, High : 15, Middle : 7
Search num :60, current mid element :67
67 is greater than 60
---------------------------------
---------------------------------
Low : 0, High : 6, Middle : 3
Search num :60, current mid element :9
9 is less than 60
---------------------------------
---------------------------------
Low : 4, High : 6, Middle : 5
Search num :60, current mid element :36
36 is less than 60
---------------------------------
---------------------------------
Low : 6, High : 6, Middle : 6
Search num :60, current mid element :44
44 is less than 60
---------------------------------
---------------------------------
Low : 7, High : 6
high is lesser than low ....so stops here...means not found....
---------------------------------
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.