Interpolation search, Computer Engineering

Assignment Help:

Interpolation Search

The next task is to implement a variable size decrease-and-conquer solution to search. See Levitin [2007] pp 190 for a detailed description of the interpolation search algorithm.

ALGORITHM InterpolationSearch (A[0 . . . n - 1], k)
// A variable-sized decrease and conquer search in an ordered list.
// INPUT : An array A[0 . . . n - 1] of ordered elements, and a search key k.
// OUTPUT : an index to the position of k in A if k is found or -1 otherwise.
1: l ← 0; r ← n - 1
2: while A[l] < k and A[r] ≥ k do
3: m ← l + (k-A[l])·(r-l)
A[r]-A[l]
4: if A[m] < k then
5: l ← m+ 1
6: else if A[m] > k then
7: r ← m- 1
8: else
9: return m
10: if A[l] = k then
11: return l
12: else
13: return -1

Algorithm InterpolationSearch shows the pseudocode for this solution. Implement the algorithm.


Related Discussions:- Interpolation search

Explain transformational analogy, Question 1 Why is it important that a...

Question 1 Why is it important that an expert system be able to explain why and how questions related to a problem solving session. 2 Give the architecture of an Expert syst

What is digitizers, What is Digitizers A common device for drawing, pai...

What is Digitizers A common device for drawing, painting, or interactively selecting coordinate positions on an object is a digitizer. These devices can be used to input coordi

Connectives in first-order logic sentences, Connectives in first-order logi...

Connectives in first-order logic sentences - Artificial intelligence We may string predicates together into a sentence in the same way by utilising connectives that we did for

What is a message in mqseries, A message is a string of bytes that has mean...

A message is a string of bytes that has meaning to the applications that use it Message = Header(s) + Application Data A message having of a header and the attached applicat

Techniques are used to increase the clock rate r, What techniques are used ...

What techniques are used to increase the clock rate R? Ans: The 2 techniques used to increase the clock rate R are: 1. We can reduce the amount of processing done in one basi

What is internet service providers, Q. What is Internet Service Providers? ...

Q. What is Internet Service Providers? Nobody truly owns the Internet however it is maintained by a group of volunteers interested in supporting this mode of information interc

Determine octant to hexadecimal conversion, What is the Octant to hexadecim...

What is the Octant to hexadecimal conversion of 734 ? Ans. (734) 8      = (1 D C) 16 0001 ¦ 1101 ¦ 1100 1         D         C

Constant voltage sources, Constant Voltage Sources An ideal constant v...

Constant Voltage Sources An ideal constant voltage source maintains a given voltage across its load regardless of the current drawn from it .Most 'every-day' power supplies a

Illustrate characteristic tables of flip-flops, Q. Illustrate Characteristi...

Q. Illustrate Characteristic tables of flip-flops? Excitation Tables Characteristic tables of flip-flops present the subsequent state when inputs and present state are kno

What is meant by bitwise operations, What is meant by bitwise operations? ...

What is meant by bitwise operations? C has distinction of supporting special operators known as bit wise operators for manipulation of data at bit level. These operators are us

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd