Initial Release
This project implements a Trie (prefix tree) data structure in C to enable fast and efficient prefix-based operations on a collection of alphanumeric words. The system supports insertion of words into the trie, checking whether a given prefix exists, and retrieving all words that share a common prefix. It is optimized for lowercase letters (a-z) and digits (0-9), making it suitable for a wide range of applications such as search engines, autocomplete systems, and dictionary utilities.
Key Features:
Alphanumeric Support: The trie handles both letters and digits, giving a total of 36 possible child nodes per trie node.
Efficient Word Insertion: Words are inserted character by character, and new trie nodes are dynamically created as needed.
Prefix Lookup: Allows users to check if any word in the trie begins with a given prefix.
Auto-suggestions: Once a prefix is found, the trie recursively retrieves and displays all words that begin with that prefix.
Memory Management: The trie is built with dynamic memory allocation and includes a cleanup function to free all allocated memory when it is no longer needed.
Reusable Design: The code is modular, and exported functions are marked for use in shared libraries or integration with larger applications.
Preloaded Data:
The trie is automatically initialized with a sample set of words such as "diabetes", "diagnosis", "dialysis", "data", "dare", "daredevil", "daring", "daringly", "dark", "dashboard", and "developer". This allows immediate testing of prefix search and auto-suggestion functionality.
Typical Use Cases:
Implementing autocomplete in terminals or GUIs
Real-time search filtering
Predictive typing
Text editors and IDE plugins
Embedded or low-memory environments where efficient string matching is required
Functions Provided:
insert(): Adds a word to the trie
search(): Checks if a prefix exists in the trie
print_words_with_prefix(): Displays all words matching a prefix
free_trie_memory(): Cleans up the entire trie to avoid memory leaks
lookup_prefix(): Public API for checking prefix existence
initialize_trie(): Loads default words into the trie (only once)