Created
May 19, 2025 08:09
-
-
Save paratechnical/cb0f77848f2ef304894a123fc83bd522 to your computer and use it in GitHub Desktop.
C# prefix tree main program
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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