Questions tagged [trie]

A tree-like data structure used to hold an associative array, also called a Prefix Tree.

Tries are specialized data structures where a word can be stored as a sequence of characters. Reading the word involves traversing down the branch of the tree. At each node, the possible completions of the partial word can be found by traversing down all possible paths to the leaf level. It is useful for implementing dictionary based functionality such as autocomplete.

1108 questions
-1
votes
1 answer

Trie based keyword searching vs Binary search

I implemented a trie based search and compared it with binary search. According to me trie based search should be more optimum than binary search when we have huge text files but when i used java's clock function to check the time, results were…
Ramesh
  • 167
  • 1
  • 10
-1
votes
1 answer

Suffix Trie and Suffix Tree

I understand the difference between (Prefix) Trie, a Suffix Trie and a Suffix Tree and I am trying to write Java code for both. What is the Java representation/structure of the SuffixTrieNode and SuffixTreeNode class? SuffixTrie…
Dev Dev
  • 31
  • 4
-1
votes
2 answers

How to find and rank all prefixes in a list of strings?

I have a list of strings and I want to find popular prefixes. The prefixes are special in that they occur as strings in the input list. I found a similar question here but the answers are geared to find the one most common prefix: Find *most* common…
ainvehi
  • 41
  • 6
-1
votes
1 answer

Object array parameter--error: field ‘letters’ has incomplete type

struct Trie { Trie letters [27]; bool hasLetter; bool EOW; ... } error: field ‘letters’ has incomplete type I am getting this error and have not been about to figure out what's wrong. I am trying to create a Trie using an array and…
-1
votes
1 answer

Would someone care to identify what might cause a segfault in my code?

This is for my CS50 assignment. I have to make a spell-checker that loads a dictionary into trie data structure. The segfault doesn't happen until the file size increases. //Trie structure typedef struct node { bool is_word; struct node*…
-1
votes
1 answer

Trie algorithm query

I am working on simple problem of constructing sentence out of line with no space and punctuations. So it needs dictionary to find if such word exist. For eg. Below is sample of how i created trie in python using dict. Trie = {o: {on: {one:…
Ninad Mhatre
  • 549
  • 1
  • 7
  • 17
-1
votes
1 answer

How to search for a word in a tree represented as a dictionary of dictionaries in python?

I have a dictionary of words like this - {"a": {"b": {"e": {}, "f": {}, "g": {"l": {}, "m": {}, "n": {}}}, "c": {"h": {}, "i": {}}, "d": {"j": {}, …
-1
votes
1 answer

Python Trie implementation why create temporary variable

I looked at this code: >>> _end = '_end_' >>> >>> def make_trie(*words): ... root = dict() ... for word in words: ... current_dict = root ... for letter in word: ... current_dict = current_dict.setdefault(letter,…
Kevin Zhao
  • 2,113
  • 2
  • 14
  • 18
-1
votes
1 answer

Trie - finding all possible sentences

I am doing the following task (in c#): We have a group of letters and an english dictionary. Find all possible combinations of words that are created from the letters provided. To do that, I use trie data structure - I search for words and all…
macpak
  • 1,190
  • 1
  • 14
  • 28
-1
votes
2 answers

Trie data structure returning null even after insertion in java

I have a TrieNode class that defines my node of the trie. I have a trie class that uses TrieNode build a trie. My intention is to insert strings into the trie. I don't understand why is the output of my program null. There is some very fundamental…
-1
votes
2 answers

Hash Function for Trie based implementation

I am supposed to build a dictionary Trie and use Nodes. I need to store them in a hashtable. I need to create a Hash Function to place the nodes in the correct location. How can i convert the String to an integer in the Hash Function?
-1
votes
1 answer

PHP T9 Dictionary Implementation using Trie

I want simplified implementation of T9 input method for mobile in PHP i.e. either using Trie or any other simple and best possible solution. Any help will be highly appreciated.
-1
votes
1 answer

What is a decimal search tree?

I was given the following assignment, which I don't fully understand: Write a program to implement a “Decimal Search Tree”, a popular tool used for searching in Libraries, police stations, Traffic control, ….. A Decimal search tree is a tree where…
-1
votes
2 answers

search string for longest keyword

I'm using java, and have a large-ish (~15000) set of keywords (strings), and I have a document (string) that contains these keywords periodically. I'd like to find the indices of each use of the keywords in the document, with a preference to longer…
user1535846
  • 15
  • 1
  • 5
-1
votes
2 answers

Adapting pseudocode to java implementation for finding the longest word in a trie

Referring to this question I asked: How to find the longest word in a trie? I'm having trouble implementing the pseudocode given in the answer. findLongest(trie): //first do a BFS and find the "last node" queue <- [] queue.add(trie.root) last <-…
user1766888
  • 417
  • 1
  • 8
  • 21