# Thread: binary and lineary search

1. Member
Join Date
Mar 2011
Posts
2
Rep Power
0

## binary and lineary search

consider an array storing the values 1 through 1000 in that order. Identify the sequence of probes that would be made in searching for the value 487 for both the linear and binary search. How many probes are there for the linear and binary search?

That is the question. I have a binary and linear search programs but I cant seem to add a counter.

2. Is this a homework assignment?

If it is, instead of my giving you the answer, I will direct you to learn the difference between linear and binary.
algorithm - What is the difference between Linear search and Binary search? - Stack Overflow

After reading and understanding the difference this problem is trivial.(this can be done very easily with pen and paper)

3. Member
Join Date
Mar 2011
Posts
2
Rep Power
0
it is a homework problem and i did work it out on paper and got 12 as the answer for the binary search but i just want to make sure that its correct

4. Alright, manually code the binary search and have it return an int instead. each time it cuts in half you should increment the counter until the value is found, and when it is, simply return the counter.