Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save paratechnical/cb0f77848f2ef304894a123fc83bd522 to your computer and use it in GitHub Desktop.

Select an option

Save paratechnical/cb0f77848f2ef304894a123fc83bd522 to your computer and use it in GitHub Desktop.
C# prefix tree main program
static void Main(string[] args)
{
Tree prefixTree = new Tree();
prefixTree.AddWord("abc");
prefixTree.AddWord("abcd");
prefixTree.AddWord("abcde");
prefixTree.AddWord("abcdef");
prefixTree.AddWord("ab123cd");
prefixTree.AddWord("abc123d");
prefixTree.AddWord("abc132d");
string word = "abc";
if (prefixTree.Find(word))
{
var matches = prefixTree.GetMatches("abc");
Console.WriteLine("gasit");
Console.WriteLine("Autocomplete:");
if (matches.Count > 0)
foreach (var m in matches)
Console.WriteLine(m);
}
else
Console.WriteLine("nu gasii nimic");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment