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
5
votes
2 answers

Disadvantages of tries

I've been studying tries and checking out their advantages and disadvantages. They're quite useful in many practical applications like dictionary, spell checkers etc due to their constant O(m) look-ups (where m is length of the string) and other…
gaurav jain
  • 3,119
  • 3
  • 31
  • 48
5
votes
1 answer

How to generate string for bash word-expansion?

Bash can generate multiple strings from single, if you use {...,...} syntax. Like here: $ echo pgdb{200,10{0,1}} pgdb200 pgdb100 pgdb101 Is there any way to take a list of strings and produce (hopefully shorter) string that, upon processing via…
someone
  • 51
  • 2
5
votes
6 answers

scrabble solving with maximum score

I was asked a question You are given a list of characters, a score associated with each character and a dictionary of valid words ( say normal English dictionary ). you have to form a word out of the character list such that the score is maximum…
5
votes
1 answer

"Simple" Trie Implementation

I need to implement a Trie (in Java) for a college project. The Trie should be able to add and remove Strings (for phase 1). I have spent several hours each day (for the last few days) trying to figure out how to do this and FAILED miserably each…
5
votes
1 answer

How to perform a Trie search using an autocompleteTextView in android?

I need to implement an AutocompleteTextView with a Trie search. I am using a Vertex class and a Trie class for the Trie tree data structure and an adapter for customize the view of the dropdown box of the autocompleteTextView. Here are all the…
tonix
  • 6,671
  • 13
  • 75
  • 136
5
votes
5 answers

How to do fast prefix string matching in Scala

I'm using some Java code to do fast prefix lookups, using java.util.TreeSet, could I be using scala's TreeSet instead? Or a different solution? /** A class that uses a TreeSet to do fast prefix matching */ class PrefixMatcher { private val _set =…
waterlooalex
  • 13,642
  • 16
  • 78
  • 99
5
votes
1 answer

Suffix tree VS Tries - in plain English , what's the difference?

I've taken a look at this questions , but I still don't see the difference between a Suffix tree and a Trie . Both have all the substrings of a given string , so where do they differ from one another ?
JAN
  • 21,236
  • 66
  • 181
  • 318
5
votes
1 answer

How to print all words stored in a Tree , wherin trie has been implemented using Hashmap in Java?

I want to print or retrieve all the words stored in Trie Data Structure. This is because I want to compute Edit distance between a misspelled word and a word in Dictionary. Therefore I was thinking of retrieving each word from Trie and compute Edit…
user2281107
  • 319
  • 2
  • 5
  • 14
5
votes
2 answers

new not called, yet memory allocated

I have written a simple Trie implementation. Here is the source code: #include #include typedef unsigned int uint; class Trie { public: class Node { public: Node(const char & _value); ~Node(); …
Anupam Srivastava
  • 789
  • 1
  • 8
  • 25
5
votes
2 answers

Any trie implementation in java( with maven repo )

From this question, there seems to be a Patricia Trie implementation, but there is no maven repo for it. In any case I can't find the trie in Gauva/Google Collections. Does anyone know any Trie implementation library in java, that has a maven…
Suraj Chandran
  • 24,433
  • 12
  • 63
  • 94
5
votes
2 answers

How to find the longest word in a trie?

I'm having trouble understanding the concept of a trie. From the "trie" wikipedia entry I have this picture: If I see this correctly, all leaf nodes in a trie will have the entire word spelled out and all parent nodes hold the characters leading up…
user1766888
  • 417
  • 1
  • 8
  • 21
4
votes
3 answers

Find anagram of input on set of strings..?

Given a set of strings (large set), and an input string, you need to find all the anagrams of the input string efficiently. What data structure will you use. And using that, how will you find the anagrams? Things that I have thought of are…
Kshitij Banerjee
  • 1,678
  • 1
  • 19
  • 35
4
votes
1 answer

Pre-populated Trie

Background: My CSS360 group is attempting to create an Android application that will include an auto-complete search feature. The data that we'll be searching consists of around 7000 entries, and will be stored in a SQLite database on the phone…
Alex Jansen
  • 1,455
  • 5
  • 18
  • 34
4
votes
1 answer

Implementing T9 text prediction

I have a T9 dictionary in memory (trie/hash_map). The dictionary contains word-rating pairs, so when a word is picked from dictionary, its rating increments, and the word-rating pair goes up in the word list. Let's say that there is a method to…
sashab
  • 1,534
  • 2
  • 19
  • 36
4
votes
1 answer

Difference between BST , Hashing , Tries and map

I read some blog and tutorial on Tries , hashing, Map(stl) and BST. I am very confused in which one is better to use and where. I know that to make such difference between them are nonsense because they are all implementation dependent. Would you…
Amit Pal
  • 10,604
  • 26
  • 80
  • 160