I haven't got the definitive answer, but I suppose it depends on what
criteria you use for the search and how many entries there are.
Searching by name, surname and address can give you multiple results, so the
search algorithm must take this into acount.
If you search by phone number, you should only get one result.
If you are searching the phone directory for the whole USA, you need a
different strategy than if you are searching your companies local branch.
For the local office scenario, you could probably load the whole directory
into an array in memory and do a linear search.
If you are searching the USA directory, this wouldn't be practical. Another
aspect of the USA scenario is that people living in New York probably don't
want people living in Los Angeles.
Chris
Irfan said:
I am interested in knowing the best algorithm to search a phone directory.
Can any one tell me whats the best algorithm to search a phone directory.
Also, if you can point me to any sample code that would be great.