Exercise
- On average, how many comparisons are required in a linear search of
n
elements? - Assume there are eight elements in a sorted array. What is the average number of comparisons that will be required if all the searches are successful and if the binary search algorithm is used?
- What is the worst-case time complexity of the binary search algorithm?
- When should the interpolation search algorithm perform better than the binary search algorithm?
Join our community on Discord
Join our community’s Discord space for discussions with the author and other readers: https://packt.link/MEvK4