i am given an assignment to write code on interpolation search binary search(searching an integer in an ordered list). bt i dont have a clear idea about about both of them as i missed the theory class.so can anyone suggest me from where i can get satisfying information about them?

Recommended Answers

All 8 Replies

We just had a wonderful example of a binary search program in "Snippets" section of this forum, about two weeks ago.

bt how will i find it?

bt how to find it?

Go to the main C forum, and you'll see the grey tab of "Snippets", click on it.

how to count comparison in binary search and interpolation search. is the number of comparison=number of iteration?or for binry search where we have two if conditions under the while loop ,the comparison will be 2*NUMBER OF ITERATION(one comparison for each if condition) or only one comparison for entering the while loop for once?

Every time the program makes a new guess at the answer, you should count one more comparison.

The number of if or else statements doesn't matter, unless a new guess is made, inside it.

In the binary loops I've seen, only one guess per iteration is made. Note that anyone could create a binary loop which made two guesses each iteration, but I have never seen that -- it's just a logical possibility.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.