Think about using tries.. they are a pretty good data structure for such
lookup.
On 2/14/07, new_dude [EMAIL PROTECTED] wrote:
We will look up someone's phone number using his name.
Does B+ tree handle the case when more than one person have the same
name but different
numbers? thanks
It does depend on the size of the problem you have in mind. Tries can be
expensive for names depending on the sparseness of the data set, you may
waste a lot of pointers. If you use B-Trees they may be good in such cases.
B-trees are generally a bit better when it comes to data stored in a disk
A good hash organization may also do well.
(http://www.cse.yorku.ca/~oz/hash.html). One needs to decide on the
criterion on which to measure the goodness.
A trie would also be a good solution, provided the implementation is
done the right way...
http://en.wikipedia.org/wiki/Patricia_trie
You
I would recommend using a trie, and a list of all numbers for the same name
at a terminating point of the trie.
Regards,
Aakash
On 2/14/07, Karthik Singaram L [EMAIL PROTECTED] wrote:
It does depend on the size of the problem you have in mind. Tries can be
expensive for names depending on the
And from my experience as an interviewer and as a person appearing for an
interview this is the answer I would expect, but would love to hear other
solutions and the trade offs between a trie and a b-tree and as is always
the case, usecase drives the selection of datastructure.
If you need
i think tree (b tree) will do the trick ,,
,,,
dont know much ,,, :(
how about implementing a linked list :)
as record of a single guy can be stored in single list
?? (not sure ,,getting intiuation of error in logic )
--- Arun [EMAIL PROTECTED] wrote:
i think a B+ tree is efficient for having