March 2019
Intermediate to advanced
336 pages
9h 9m
English
The interpolation search algorithm searches for the element in a sorted collection. The algorithm finds the input element at an estimated position by diminishing the search space before or after the estimated position. The time complexity of the search algorithm is of the order O(log log n).
The following code snippet implements the interpolation search algorithm. The InterpolationSearch function takes the array of integer elements and the integer element to be found as parameters. The function finds the element in the collection and returns the Boolean and the index for the found element:
//main package has examples shown// in Go Data Structures and algorithms bookpackage main// importing fmt packageimport ( "fmt")//interpolation ...
Read now
Unlock full access