Skip to content

Latest commit

 

History

History
 
 

Prefix_Trie

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Star Badge Open Source Love

🛠️ Description

Implementation of a simple Prefix Trie in Python. It allows for insertion, search, and checks if a string in the Trie starts with a prefix.

⚙️ Languages or Frameworks Used

The program was created with Python3.

🌟 How to run

To use this Trie, import the Trie class by adding: from trie import Trie to the top of your python file.

Then, you can create a Trie using the constructor trie = Trie()

Methods:
insert(word) - Inserts word into Trie
search(word) - Returns if word is in Trie
starts_with(prefix) - Returns if a word in Trie starts with prefix\

To insert, run trie.insert("word")
To search, run trie.search("word")
To check if the trie contains a prefix, run trie.starts_with("w")

🤖 Author

Tim Vuong

Credits to LeetCode problem: https://leetcode.com/problems/implement-trie-prefix-tree/description/