The search method that we are going to explore belongs to computers. But it can be used in many real-life situations like crime investigation, eliciting an answer in an enquiry etc,.
Consider a set of alphabetically arranged strings as given below.
1. ABC
2. BCD
3. CDE
4. DEF
5. EFG
6. FGH
7. GHI
8. HIJ
9. IJK
10. JKL
11. KLM
12. LMN
13. MNO
I want to find the location of KLM. Select the middle string in the list. That is 7. GHI. Since KLM is less than GHI, KLM must be present below it not above it. So leave out the strings above 7. Now we are left with,
7. GHI
8.HIJ
9. IJK
10.JKL
11.KLM
12.LMN
13. MNO
Now again go for the middle element which is 10.JKL. Again KLM is less than JKL. Hence leave out the top- half of the list. Now we are left with,
10. JKL
11. KLM
12. LMN
13. MNO
Now, if you select the middle element, you will land in KLM and its location is 11. So we made it in 3 steps.
This kind of searching is called binary searching. Since we divide the list into 2 halves every time and leave out one half each time. This is one of the fastest searching methods. Suppose you want to search a data base of 100000 names. In the first step we can eliminate 50000 names and in the second step, 25000 names and so on.
Say, a crime is committed and you want to find the culprit. The investigating inquiry with the concerned people may go on as given below.
q1. Is the culprit alive or dead?
q2. Is the person man or woman?
q3. Is he /she known or unknown person?
q4. Is the person belongs to this town or not
q5. Is he /she belongs to your family or your office?
In each question, we eliminate so many number of suspects and finally may zero in on the enemy.
Long time ago, there was a television show by name 'what is in your mind?'. The participant in the show has to think of a celebrity's name. The expert shoots 15 questions to the participants one by one and ultimately finds out the name in the mind. The questions were mainly based on binary elimination method.
I remember a scene of a movie, where the guy finds out the address of a Girl's college based on just a book with her and the local train that she catches during her morning sojourn.
ReplyDeleteIndeed a simple and effective method to search a required data.