兄台所见极是

来源: 2009-01-20 22:46:54 [旧帖] [给我悄悄话] 本文已被阅读:
The keywords are provided sorted already. Initially it's just gonna be sorted alphabetically. Later may add the "most popular" parameter like you said.

There're the generic types of SortedDictionary<>, SortedList<> in .NET. However, not sure how useful these could be in this case, as it's not practical to build an index that covers all the possible character combinations. If we only match the first two letters, theoratically it's an index size of 26x26. It grows exponencially as the number of match letters increases.

So I'm thinking instead of building an elegant solution, the next best thing might be to simply break down the 50,000 into numerous smaller with the first two letters as the key:

aa list1
ab list2
ac list3
...

Of course some of these lists would be far bigger than some others (because a lot of words would start with, sya "st", whereas few words would start with , say "xx", ).

Then starting from the third character, "brutal force" match would be applied (like the FindAll() method). What you guys think?

If we figure out a perfect solution to this, guys, let's start our own Qooqle.