https://github.com/dongyuwei/tiny-trie-js
simple trie data structure
https://github.com/dongyuwei/tiny-trie-js
trie
Last synced: 4 months ago
JSON representation
simple trie data structure
- Host: GitHub
- URL: https://github.com/dongyuwei/tiny-trie-js
- Owner: dongyuwei
- License: mpl-2.0
- Created: 2019-05-27T06:54:08.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-04-11T03:58:11.000Z (about 3 years ago)
- Last Synced: 2025-02-09T17:05:41.367Z (4 months ago)
- Topics: trie
- Language: TypeScript
- Size: 18.6 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tiny-trie-ts
Simple [trie](https://en.wikipedia.org/wiki/Trie) data structure implemented in TypeScript.
## Test
`pnpm test`
## API
```js
const { Trie } = require('tiny-trie-ts');
const trie = new Trie();
```1. `trie.insert(key, value);`
2. `trie.find(key);`
3. `trie.keysWithPrefix(prefix);`
4. `trie.serialize();`
5. `trie.deserialize(serialized);`The `serialize` and `deserialize` algorithm is variant of [serialize-deserialize-n-ary-tree](https://www.geeksforgeeks.org/serialize-deserialize-n-ary-tree/)