Question: 1. Consider the following list of numbers: 7 15 23 25 44 86 92 118 123 144 177 200 212 243 270 285 Using a
1. Consider the following list of numbers:
7 15 23 25 44 86 92 118 123 144 177 200 212 243 270 285
Using a standard linear search and assuming the numbers are not ordered, how many comparisons are needed to determine whether the following numbers occur in the list:
a. 25
b. 130
c. 270
d. (extra credit 5 points): If the linear search assumes the numbers are in order, how many comparisons are needed to determine is 130 is in the list. Explain your answer.
Using a binary search, how many comparisons are needed to determine whether the following numbers occur in the list:
e. 25
f. 130
g. 270
2. Demonstrate how you counted comparisons for 1g. 270, above.
3. Assume we have 4000 ordered elements in a list to be searched.
a. What is n in this case.
b. What would be the worst case number of comparisons in a linear search of these elements (give a number)?
c. What would be the worst case number of comparisons for a binary search of these elements (give a number)?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
