Binary Searching: Earl Paine Stu Schwartz
Binary Searching: Earl Paine Stu Schwartz
Who we are
Combining curriculums The art of collaboration
The problem
You have 10 alphabetized names along with the last 4 digits of their social security number. You input a name and the program will search for it.
If found, the SS# 4 digits will appear If not found, the user will be asked the persons SS# 4 digits which will be added to the list.
Ex: Barnes
2. If name is not found, it will take 10 searches to ascertain that information. A list of 500 names requires 500 searches.
Note: in this age of speed, 500 searches can be done in a microsecond. It is hard to justify a need to generate a more efficient method to save such a small amount of time. It should be mentioned that if there were 10 million names with the process continuing over and over, the need for efficiency is much more pronounced. Hence a more efficient method is needed.
Pass 5: low=4, high = 4: STOP - name not found Every name from position target + 1 and below must be pushed down so name can be inserted into target.
The maximum number of searches is the smallest integer greater than log n/log 2
With the incredible speed of todays computers, a binary search becomes necessary only when the number of names is large.