Imports System
Public Class Program
Public Shared Function interpolation_search(ByVal arr As Integer(), ByVal item As Integer) As Integer
Dim low As Integer = 0
Dim high As Integer = arr.Length - 1
Dim mid As Integer = -1
Dim index As Integer = -1
While low <= high
mid = low + (((high - low) / (arr(high) - arr(low))) * (item - arr(low)))
If arr(mid) = item Then
index = mid
Exit While
Else
If arr(mid) < item Then
low = mid + 1
Else
high = mid - 1
End If
End If
End While
Return index
End Function
Public Shared Sub Main(ByVal args As String())
Dim arr As Integer() = New Integer() {2, 5, 6, 8, 9, 12, 23, 36, 40, 46, 50, 51, 55, 61, 72, 86, 97}
Dim item As Integer = 51
Dim index As Integer = interpolation_search(arr, item)
If index <> -1 Then
Console.Write("index = " & index)
Else
Console.Write("Not found")
End If
End Sub
End Class
' run:
'
' index = 11
'