Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gavindsouza/data-structures-and-design-patterns
Stuff that I do to scratch an itch
https://github.com/gavindsouza/data-structures-and-design-patterns
data-structures design-patterns monad python trie
Last synced: about 2 months ago
JSON representation
Stuff that I do to scratch an itch
- Host: GitHub
- URL: https://github.com/gavindsouza/data-structures-and-design-patterns
- Owner: gavindsouza
- License: apache-2.0
- Created: 2022-07-09T18:28:48.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-09T11:12:37.000Z (about 2 months ago)
- Last Synced: 2024-11-09T12:19:50.068Z (about 2 months ago)
- Topics: data-structures, design-patterns, monad, python, trie
- Language: Python
- Homepage:
- Size: 13.7 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Stuff that I do to scratch an itch
Implemented a trie in Python because I've been obsessed with it since I learnt about it first a few years ago. I'll be adding more stuff that I "feel" like trying or if I have any newer, better ideas.
Been learning Rust because it's so cool. Started implementing Trie in Rust and wanted to benchmark while integrating it as a Python module :D That's a wip until I decide to get back to it.
### Contents
1. Trie
A bare bones implementation of Trie using Dict that supports the following operations:
- Add a word (`str`) to the Trie
- Check if word exists in Trie
- Generate all words in Trie from a particular nodeThe module consists of:
- a Python implementation
- a Rust equivalent _[wip]_Benchmarks:
Size of input dictionary: 966,550 words. Size of test dictionary: 10,000 words. Numbers generated using _Python3.10.4_ on _AMD Ryzen 7 PRO_.
| Structure | Inserting dictionary | Full Search | Prefixed Search |
| - | - | - | - |
| Trie _(Dict based)_ | 2.18e+00s | 1.19e-02s | 9.88e+00s |
| Set | 1.11e-01s | 8.28e-04s | 1.26e-03s |
| List | 2.34e-02s | 4.99+01s | 6.61e+02s |> The `suggestions.py` script provides a use case for Trie that takes string inputs and give suggestions for similar words if the word/phrase doesn't exist in the data structure.
2. Monad