-6- An array contains the elements (2, 8,37,28,17,59,48). Using the Binary Searc
ID: 3731070 • Letter: #
Question
-6- An array contains the elements (2, 8,37,28,17,59,48). Using the Binary Search algorithm, Trace the steps followed to find (4.0.1637), At each loop iteration, including the last show the position of first, last, middle and Number of comparison. Iteration No First LastMiddle List[mid] No of comparison 2. is at Position Found = 7- Using binary search write e program to do the following A. which read 7 characters from user and search for the specific character B. Which search for random number between 1, 20 C. Which search in array of even numbers between 2, 30 and search for 16 and the index of 16 the second search target. D. Allow the user to enter array (charactet or integer) elements, and search for a specific element (by using recursion Function)Explanation / Answer
The elements of the list are : { 2,8,37,28,17,59,48}
The sorted list is : { 2,8,17,28,37,48,59}
Searching for 4.
Iteration No.
First
Last
Middle
List[mid]
No. Of Comparision
1
0
6
3
28
1
2
0
2
1
8
2
3
0
0
0
2
3
Found = False
Searching for 0.
Iteration No.
First
Last
Middle
List[mid]
No. Of Comparision
1
0
6
3
28
1
2
0
2
1
8
2
3
0
0
0
2
3
Found = False
Searching for 16
Iteration No.
First
Last
Middle
List[mid]
No. Of Comparision
1
0
6
3
28
1
2
0
2
1
8
2
3
1
2
2
17
3
4
1
1
1
8
4
Found = False
Searching for 37
Iteration No.
First
Last
Middle
List[mid]
No. Of Comparision
1
0
6
3
28
1
2
1
6
4
37
2
(37) is at index 4, location 5. Found = True
Iteration No.
First
Last
Middle
List[mid]
No. Of Comparision
1
0
6
3
28
1
2
0
2
1
8
2
3
0
0
0
2
3
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.