3
Contributors
8
Replies
10
Views
6 Years
Discussion Span
Last Post by Adak
0

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

0

bt how will i find it?

Edited by poojabi: n/a

0

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?

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.