(Linear Search Vs. Binary Search) |
|||
Line 10: | Line 10: | ||
[[Linear Search:]] | [[Linear Search:]] | ||
− | scroll through the numbers from 0 to 100 sequentially | + | scroll through the numbers from 0 to 100 sequentially in order to determine the number you are searching for. |
Latest revision as of 16:44, 5 May 2011
suppose you are searching for a number between 0 and 100, and you can only check one number at a time and determine if you are too low or two high.
to do this one would probably guess a number between 0 and 100, say 50, and determine if the number we are looking for is above or below 50. For example if the number is below fifty my next guess would be 25 and so on and so forth till the number is reached.
In order to do a binary search, the list that is being searched must be sorted.
scroll through the numbers from 0 to 100 sequentially in order to determine the number you are searching for.