Question: Given a sorted array 2, 5, 8, 12, 16, 18, 22, 25, 29, 32 and the following interpolation search algorithm. Show the steps of
Given a sorted array 2, 5, 8, 12, 16, 18, 22, 25, 29, 32 and the following interpolation search algorithm. Show the steps of the algorithm when 25 is searched. Also, when 26 is searched. array a, size n, key k left index l, right index r function intSearch (a, 1, r, k) while alla[r] Aa[l] < k < a[r] do P+ k-all x (r1)+1 a[r] - a[l] if k = a[p] then return p else if ka[p] then rp-1 else k > a[p] 1p+1 if k = a[l] then else return return -1 Not Found
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
