Question 1 Given the following array of numbers: Trace the Binary Search algorit
ID: 3822731 • Letter: Q
Question
Question 1 Given the following array of numbers:
Trace the Binary Search algorithm that follows, to find an item whose value is 10.
Notes: First/Last/Middle refer to indices, not values.
Use integer division when calculating Middle.
Fill unused cells with an x.
First
Comparison
1.
2.
3.
Return Value (True/False):
ANSWER:____________________________
Question 2 Given the following array of numbers:
Trace the Binary Search algorithm that follows, to find an item whose value is 60.
Notes: First/Last/Middle refer to indices, not values.
Use integer division when calculating Middle.
Fill unused cells with an x.
First
Comparison
1.
2.
3.
4.
Return Value (True/False):
answer: ___________________________
Question 3 Given the following array of numbers:
Sort the list using the Selection Sort algorithm that follows. Show each iteration using the following table.
Notes: firstUnsorted & indexOfSmallest refer to indices.
smallest refers to a value.
Fill unused cells with x.
indexOfSmallest
List
indexOfSmallest
List
indexOfSmallest
List
indexOfSmallest
List
indexOfSmallest
List
indexOfSmallest
List
Question 4
Given the following array of numbers:
Sort the list using the Optimized Bubble Sort algorithm that follows. Show each iteration using the following table.
Note: firstUnsorted refers to an index.
Fill unused cells with x.
firstUnsorted
__________________
swap (T/F)
___________
List
firstUnsorted
_____________
swap(T/F)
------------------
List
firstUnsorted
______________
swap(T/F)
____________
List
firstUnsorted
_____________
swap(T/F)
__________
List
firstUnsorted
_____________
swap(T/F)
__________
List
firstUnsorted
___________
swap(T/F)
_________
List
First
Last MiddleComparison
10 50 65 70 86Explanation / Answer
Solution:
Qs1:
Given Array : 6 8 10 25 50 65 70 86
Binary Search to find 10:
First Last Middle Comparison
6 86 25 Middle value > Search value
6 10 8 Middle value < Search value
10 10 10 Middle value = Search value
Answer : True
Qs2:
Given Array : 6 8 10 25 50 65 70 86
Binary Search to find 60:
First Last Middle Comparison
6 86 25 Middle value < Search value
50 86 65 Middle value > Search value
50 50 50 Search value not found
Answer : False
Qs3:
Given Array : 7 2 8 3 9 5
firstUnsorted smallest indexOfSmallest
7 2 2
List:
2 7 8 3 9 5
firstUnsorted smallest indexOfSmallest
7 3 4
List:
2 3 8 7 9 5
firstUnsorted smallest indexOfSmallest
8 5 6
List:
2 3 5 7 9 8
firstUnsorted smallest indexOfSmallest
7 7 4
List:
2 3 5 7 9 8
firstUnsorted smallest indexOfSmallest
9 8 6
List:
2 3 5 7 8 9
Qs4:
Given Array : 7 2 8 3 9 5
firstUnsorted swap (T/F)
1 F
List:
2 7 8 3 9 5
firstUnsorted swap (T/F)
7 F
List:
2 7 8 3 9 5
firstUnsorted swap (T/F)
8 F
List:
2 7 3 8 9 5
firstUnsorted swap (T/F)
8 F
List:
2 7 3 8 9 5
firstUnsorted swap (T/F)
9 F
List:
2 7 3 8 5 9
firstUnsorted swap (T/F)
2 T
List:
2 7 3 8 5 9
firstUnsorted swap (T/F)
7 F
List:
2 3 7 8 5 9
firstUnsorted swap (T/F)
7 F
List:
2 3 7 8 5 9
firstUnsorted swap (T/F)
8 F
List:
2 3 7 5 8 9
firstUnsorted swap (T/F)
8 F
List:
2 3 7 5 8 9
firstUnsorted swap (T/F)
9 F
List:
2 3 7 5 8 9
firstUnsorted swap (T/F)
2 T
List:
2 3 7 5 8 9
firstUnsorted swap (T/F)
3 F
List:
2 3 5 7 8 9
firstUnsorted swap (T/F)
5 F
List:
2 3 5 7 8 9
firstUnsorted swap (T/F)
7 F
List:
2 3 5 7 8 9
firstUnsorted swap (T/F)
8 F
List:
2 3 5 7 8 9
firstUnsorted swap (T/F)
2 T
List:
2 3 5 7 8 9
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.