c# - Would a Patricia Trie algorithm be the fastest way to do a 'prefix' search (i.e. Starts With search) in .NET? -
i have file contains lot of names of people , meta each person.
i'm trying search people, given search query.
so i'm first going exact search (easy, implimented dictionary key lookup).
if fails (or fails reach max number of records specificed), hoping try , go on keys again , startswith check.
now works fine. curious if there's better way this. looking around interwebs looks there's data structure called patricia trie alg.
so ..
- is
patricia trierecommended way of doingstartswithcheck on large set of string-keys? - if yes, there nuget package this?
- no - no want
containscheck. nope. nada. zilch.
edit 1:
also, data loaded in once @ app startup i'm happy incur slower 'build' step while creating/populating data structure. if runtime search-perf better.
also, understand word 'performance' depends on heaps of factors, number of items stored , size of search queries etc. more academic question wish code-comparison vs microptimisation anti-pattern.
edit 2:
also, this previous question sorta talks similar problem i'm having answers seem talking substring search , not prefix (i.e. startswith) search.
thank in advance or feedback. cheer!
Comments
Post a Comment