Пример #1
0
        public void Insert(string word)
        {
            if (string.IsNullOrEmpty(word))
            {
                throw new Exception();
            }

            Node current = _root;

            foreach (var ch in word)
            {
                if (!current.HasChild(ch))
                {
                    current.AddChild(ch);
                }

                current = current.GetChild(ch);
            }
            current._isEndOfWord = true;
        }