Third Searching Algorithm

 

The results from the first and second algorithms were different, because the data are randomly generated each time the applet is activated. However, there was another difference: The number of comparisons to find an item in the list increased with the value of the item. In contrast, the number of comparisons for those items that were not found remained constant. The reason for these two observations is that the list items are in sorted order, but the algorithm does not take advantage of the order.

Run the applet to find the actual range of values.  Then run the applet as many times as it takes to find five items that are in the list and five items within the range that are not in the list. Record the items you used along with the number of comparisons it took to either find the item or determine that the item was not in the list.

Examine the results and hypothesize what change has been made in the algorithm.