State why a binary search cannot be used on the list fruits
fruits = ["banana", "apple", "orange", "pear", "grape", "pineapple"]
Did this page help you?
State why a binary search cannot be used on the list fruits
fruits = ["banana", "apple", "orange", "pear", "grape", "pineapple"]
How did you do?
Did this page help you?
State why binary search is considered a better algorithm than linear search.
How did you do?
Did this page help you?
A list of valid discount codes is shown below.
[NIC12B, LOR11S, STU12M, VIC08E, KEI99M, WES56O, DAN34S]
State one reason why a binary search would not be able to be used with this data.
How did you do?
Give the name of one searching algorithm that would be able to be used with this data.
How did you do?
Did this page help you?
State the comparisons that would be made when the linear search algorithm is used to search for the value 8 in the following array (array indices have been included above the array).
0 | 1 | 2 | 3 | 4 | 6 | 6 |
---|---|---|---|---|---|---|
4 | 7 | 8 | 13 | 14 | 15 | 17 |
How did you do?
State the comparisons that would be made when the binary search algorithm is used to search for the value 8 in the following array (array indices have been included above the array).
0 | 1 | 2 | 3 | 4 | 5 | 6 |
---|---|---|---|---|---|---|
4 | 7 | 8 | 13 | 14 | 15 | 17 |
How did you do?
Did this page help you?
A sample of data is shown in Fig. 4.
amber | house | kick | moose | orange | range | wind | zebra |
---|
Fig. 4
Show the stages of a binary search to find the word zebra using the data shown in Fig. 4.
How did you do?
Did this page help you?
State two advantages of a linear search compared to a binary search.
How did you do?
Did this page help you?
You are given two different lists of data: one sorted and one unsorted.
List A (Unsorted):["pear", "orange", "banana", "apple", "mango", "grape"]
List B (Sorted):["apple", "banana", "grape", "lemon", "mango", "orange", "pear", "watermelon"]
Explain, step by step, how you would use a linear search to find the word 'mango' in List A.
How did you do?
Explain, step by step, how you would use a binary search to find the word 'mango' in List B.
How did you do?
Did this page help you?
Compare the advantages and disadvantages of both linear and binary search algorithms.
Explain in which scenarios one algorithm would be preferred over the other.
How did you do?
Did this page help you?
A section of code from a linear search is given below
list = [7, 1, 4, 2, 8]
target = 4
found = False
# Loop through each element in the list
for _____ in _____(0,___(list) - 1):
Complete the missing Python code to correctly loop through each element in the list.
How did you do?
State the purpose of -1
in the loop in part A.
How did you do?
Did this page help you?
You are given the following sorted list of numbers:
[2, 9, 15, 22, 30, 41, 53, 66, 71, 83, 97]
Complete a binary search to find the number 22
.
Show each step in the search, indicating the middle element and how the list is divided at each step.
How did you do?
Did this page help you?
You are given the following sorted list of words:
["apple", "banana", "cherry", "grape", "lemon", "mango", "orange", "peach", "pear", "plum", "watermelon"]
Complete a binary search to find the word peach
.
Show each step in the search, indicating the middle element and how the list is divided at each step.
How did you do?
Did this page help you?