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

Discuss the important characteristics of 8237, Question 1 Discuss the w...

Question 1 Discuss the working principle of an interrupt and hardware actions in interrupt handling 2 Discuss the important characteristics of 8237 3 Describe the format

What are the different sections of a report, What are the different section...

What are the different sections of a report? A report is categorized into many sections: The Report header: In this you place a control which must appear only at the startin

List criteria of data structures used in language processing, List the crit...

List the criteria on the basis of which data structures used in language processing can be classified. In language processing the data structures utilization can be classified

Operator, write algorithm and draw flowchart for exchange the values of two...

write algorithm and draw flowchart for exchange the values of two variables.

What is clear operation, Clear operation The clear operation compares w...

Clear operation The clear operation compares words present in A and B and produces an all 0's result if two numbers are equal. This operation is achieved by the exclusive-OR mi

Line of code of assembly language, In how many ways line of code of assembl...

In how many ways line of code of assembly language can be divided? A line of code of an assembly language program can be divided in three columns called as fields. The fields d

Write short note on quantization, Write short note on Quantization. Qua...

Write short note on Quantization. Quantization: This is the first step in PCM. The whole amplitude range of the modulating signal is divided in a number of standard levels term

What is response ratio, What is response ratio? HRRN that is Highest Re...

What is response ratio? HRRN that is Highest Response Ratio Next scheduling is a non-preemptive discipline, as same to Shortest Job First (SJF) wherein the priority of all jobs

Instruction level-levels of parallel processing, Instruction Level It r...

Instruction Level It refers to the condition where different instructions of a program are implemented by different processing elements. Most processors have numerous execution

Explain the fixed logic versus programmable logic, Explain the Fixed Logic ...

Explain the Fixed Logic Versus Programmable Logic? The Logic devices can be classified into two broad categories - fixed and programmable. The same as the name suggests, the ci

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