1- What are the requirements to be able to use a binary
search?
• On which data does the binary search work particularly well or
particularly badly?
• What is the effort of binary search in the average case or worst
case? with explanation please
2-What are the requirements to be able to use an interpolation
search?
• On which data does the interpolation search work particularly
well or particularly badly?
• What are the costs of interpolation search in the average case or
worst case? with explanation please
Binary Search
Work well with integer, double, float and char type of data but not work well with string type of data because string consist multiple characters so it requirement multiple matching within string so it take lot of time
Worst-case performance: O(log n)
Best-case performance: O(1)
Average performance: O(log n)
interpolation search
same as above
Worst-case performance: O(n)
Best-case performance: O (log log n))
Average performance: O (log log n))
Binary Search vs interpolation search
The Interpolation Search is an improvement over Binary Search for examples, where the qualities in an arranged cluster are uniformly distributed. Binary Search dependably goes to the center element to check. Then again, interpolation search may go to various areas as indicated by the estimation of the key being searched. For instance, if the estimation of the key is nearer to the last element, interpolation search is probably going to begin search close to the end side. Interpolation search works superior to Binary Search for an arranged and uniformly distributed cluster.
On average the interpolation search makes about log(log(n)) correlations (if the elements are uniformly distributed), where n is the quantity of elements to be searched. In the worst case (for example where the numerical estimations of the keys increment exponentially) it can make up to O(n) correlations.
1- What are the requirements to be able to use a binary search? • On which...