[algogeeks] Re: a data structure for phone directory

2007-02-14 Thread Vijendra Singh
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

[algogeeks] Re: a data structure for phone directory

2007-02-14 Thread Karthik Singaram L
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

[algogeeks] Re: a data structure for phone directory

2007-02-14 Thread Mayur
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

[algogeeks] Re: a data structure for phone directory

2007-02-14 Thread aakash mandhar
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

[algogeeks] Re: a data structure for phone directory

2007-02-14 Thread aakash mandhar
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

[algogeeks] Re: a data structure for phone directory

2007-02-13 Thread lali
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