Skip to content

azmuth13/Trie-Search

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trie-Search

https://trusting-wright-17c489.netlify.app/

A demo on Trie data structure

What is a trie?

A trie is a tree-like data structure whose nodes store the letters of an alphabet. By structuring the nodes in a particular way, words and strings can be retrieved from the structure by traversing down a branch path of the tree.

Building the Trie Unlike C++ where we use pointer array for each node, in javaScript we can use regular objects as simplified Hashtables.

TrieNode {
    this.value
    this.isWord
    this.addChild = function(){
      this[nextLetter] = new TrieNode()
    }

    this.a = TrieNode {}
    this.b = TrieNode {}
    this.c = TrieNode {}
    ...
}

Searching a word search.js include both linear search and TrieSearch to compare their efficiency. When a user search the result will come from TrieSearch, but both searches will run sequentially to see the advantage of logarithmic time search over linear time search.

Screenshots

Screenshot (426)

Screenshot (427)

Screenshot (428)

Screenshot (429)

About

A demo on Trie data structure

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published