Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question # 5 . By now you should be convinced that binary search requires fewer comparisons than linear search in both the worst case and
Question # By now you should be convinced that binary search requires fewer comparisons than linear search in both the worst case and the average case. However, keep in mind that binary search assumes that the elements are already in sorted order; if theyre not sorted, then it would take time to sort them before applying binary search, and sorting is a slow operation. Whereas the number of operations in the worst case to conduct binary search on a collection of N items is approximately log log N the number of operations required to sort N items is log Nlog N ie the value of N times its base logarithm. Assume you have an unsorted collection of N items, and you know you will need to make at least searches and are concerned about the worst case. How would you determine whether it would be better to conduct linear searches, or if it would be better to first sort the elements which you only need to do once and then conduct binary searches? In making this decision, follow these steps: First, calculate the number of operations it would require to conduct linear searches in the worst case. Then, calculate the number of operations it would require to sort the elements once; for simplicity, round log log up to Last, calculate the number of operations it would require to conduct binary searches in the worst case. Use the results of these three calculations to determine the answer. Show the results of your calculations for steps and then explain your answer in step
Question # By now you should be convinced that binary search requires fewer comparisons than linear search in both the worst case and the average case. However, keep in mind that binary search assumes that the elements are already in sorted order; if theyre not sorted, then it would take time to sort them before applying binary search, and sorting is a slow operation.
Whereas the number of operations in the worst case to conduct binary search on a collection of N items is approximately
log
log
N the number of operations required to sort N items is
log
Nlog
N ie the value of N times its base logarithm.
Assume you have an unsorted collection of N items, and you know you will need to make at least searches and are concerned about the worst case. How would you determine whether it would be better to conduct linear searches, or if it would be better to first sort the elements which you only need to do once and then conduct binary searches?
In making this decision, follow these steps:
First, calculate the number of operations it would require to conduct linear searches in the worst case.
Then, calculate the number of operations it would require to sort the elements once; for simplicity, round
log
log
up to
Last, calculate the number of operations it would require to conduct binary searches in the worst case.
Use the results of these three calculations to determine the answer.
Show the results of your calculations for steps and then explain your answer in step
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started