A linear search is the most basic search algorithm you can have. A linear search sequentially moves through your collection (or data structure) looking for a matching value. The worst case performance scenario for a linear search is that it needs to loop through the entire collection; either because the item is the last one, or because the item isn't found. Even thought the speed of search grows linearly with the number of items within a collection, linear searches are still used as computers can process data so quickly..
A Binary search relies on a divide and conquer strategy to find a value within an already-sorted collection. The algorithm is deceptively simple. Every iteration (loop) eliminates half of the possibilities. Take the example of guessing a number from 1-100, for every guess you make, I'll say higher or lower. The most efficient way to discover my number is to first guess 50. Lower . 23. Higher etc.. Until the number is discovered. This makes binary searches very efficient - even for large collections
In looking at this problem (and coding it) there are two approaches to consider:
1) Where the student guesses the correct number (shown below with an example between 1-1000).
This requires the use of a random number aspect to start the program and a variable to count the number of guesses with conditionals to say whether the guess was too low or too high
It also requires the adjustment of several variables while the program is being run and I added the printing out of several of the key variables just to track the mathematics was all working correctly.