コード例 #1
0
        public void TestTrieInsert()
        {
            // create root node.
            TrieNode root = new TrieNode();

            // insert the strings as dictionary
            TrieOperation operation = new TrieOperation();

            operation.Insert(root, "abc");
            operation.Insert(root, "abcd");
            operation.Insert(root, "aa");
            operation.Insert(root, "abbbaba");

            // assert for search operation
            Assert.IsTrue(operation.Search(root, "abc"));
            Assert.IsTrue(operation.Search(root, "abcd"));
            Assert.IsTrue(operation.Search(root, "abbbaba"));
            Assert.IsFalse(operation.Search(root, "abb"));

            // delete abc from Trie node
            operation.Delete(root, "abcd");

            // assert for search operation.
            Assert.IsFalse(operation.Search(root, "abcd"));
            Assert.IsTrue(operation.Search(root, "abc"));
            Assert.IsTrue(operation.Search(root, "abbbaba"));
        }