public bool SearchUtil(string word, TrieDS root, bool isCompleteSearch)
    {
        int j = word[0] - 'a';

        if (root.children[j] == null)
        {
            return(false);
        }

        if (word.Length == 1)
        {
            return(isCompleteSearch ? root.children[j].isEnd : true);
        }

        return(SearchUtil(word.Substring(1), root.children[j], isCompleteSearch));
    }
    /** Inserts a word into the trie. */
    public void Insert(string word)
    {
        TrieDS temp = root;
        int    i    = 0;
        int    j    = 0;

        for (; i < word.Length; i++)
        {
            j = word[i] - 'a';
            if (temp.children[j] == null)
            {
                temp.children[j] = new TrieDS();
            }
            temp = temp.children[j];
        }
        temp.isEnd = true;
    }
 public Trie()
 {
     root = new TrieDS();
 }