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

Develop the multi agent system, The new season of AFL, and the excited comi...

The new season of AFL, and the excited coming FIFA World Cup in South Africa this June, many sports fans are willing to find the latest results of their beloved sports teams. In th

Convert binary number in two''s compliment form, Convert binary number in t...

Convert binary number in two's compliment form 0100 1000. Converting the binary number into 2's compliment from 0100 1000 is given below: 01001000 => 10111000

Flowchart, How to calculate the flowchart

How to calculate the flowchart

Define resolution versus accuracy in mouse, Q. Define Resolution versus Acc...

Q. Define Resolution versus Accuracy in mouse? Resolution of mouse is known in CPI (Counts per Inch) it implies that number of signals per inch of travel.  This implies the mou

Multiple instruction and multiple data stream (mimd), Multiple Instruction ...

Multiple Instruction and Multiple Data stream (MIMD) In this association, multiple control units and multiple processing elements are prepared as in MISD. But the discrepancy i

Boiler troubles, Differences between internal and external treatment in boi...

Differences between internal and external treatment in boiler

Multiprogramming or multitasking, Multiprogramming or multitasking? An...

Multiprogramming or multitasking? Ans: The OS manages the concurrent execution of many application programs to make best possible use of computer resources. This pattern of si

Realize x-nor gate using nand gate, Q. A. Which gates are called Universa...

Q. A. Which gates are called Universal Gates? Why? B. State and prove any one of the DeMorgen's Laws. Show that these theorems can be extended up to any number of variables.

Example on plane, Q. If a plane is in the air also there is a fly flying in...

Q. If a plane is in the air also there is a fly flying inside the plane does the plane get heavier when the fly lands? Answer:- It is true that a fly puts weight on a plan

recycling from e-waste to resources , Make at least 6 web pages with good ...

Make at least 6 web pages with good formatting, color balance and presentation on any one of the following topics:- 1.    Recycling from E-waste to resources 2.    Light and So

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