Skip to content

Trie Class Library for C#. Support for word insertion and membership checking

Notifications You must be signed in to change notification settings

mikhail-alekseev/TrieCS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trie illustration

TrieCS

Trie Class Library for C#. Support for word insertion and membership checking

Usage

Instantiation

Get an instance of Trie using either of the following constructors

Trie trie = new Trie();
string[] words = new string[] { "SOME", "WORDS", "HERE" };
Trie trie = new Trie(words);
string filepath = @"path/to/dictionary/file"
Trie trie = new Trie(filepath);

Word Insertion

You can add new words to the trie using the public Insert method.

Trie trie = new Trie();
trie.Insert("HELLO");
trie.Insert("WORLD");

Membership checking

You can use the public Contains method to check for membership (case-sensitive).

Trie trie = new Trie();
Console.WriteLine("HELLO in Trie? {0}", trie.Contains("HELLO")); // False
Console.Insert("HELLO");
Console.WriteLine("HELLO in Trie? {0}", trie.Contains("HELLO")); // True
Console.WriteLine("HELLO in Trie? {0}", trie.Contains("hello")); // False because it is case-sensitive

Additional information

More info on tries on Wikipedia.

About

Trie Class Library for C#. Support for word insertion and membership checking

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages