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

Storing Paragraph # in Trie

I am building a Trie in Java. When searching the trie for a keyword, the entry for the keyword needs to also store which paragraphs the keyword appears in in the text. Does anyone have some insight into how I would go about storing the paragraph…
Laura
  • 1
  • 1
-1
votes
1 answer

Trie Tree Initialization

I am using C++ to construct a trie tree with a bunch of words in dictionary. This is how I defined my TrieNode and built a tree: struct TrieNode { TrieNode *children[26]; bool isWord; TrieNode(): isWord(false) {} /* to be deleted…
-1
votes
2 answers

Best practice in preserving insertion order with priority queue in case of equality for stable sorting

UPDATE Given a set of reviews provided by the customers for different hotels and a string containing “Good Words”, you need to sort the reviews in descending order according to their “Goodness Value” (Higher goodness value first). We define the…
srs
  • 330
  • 1
  • 11
-1
votes
1 answer

character disappers while using getline()

so here's the code: #include #include "Trie.h" using namespace std; void main() { string input; Trie dictionary('\0'); while (true) { getline(cin, input); if (input[0] != '.') { …
AmitBL
  • 89
  • 4
  • 12
-1
votes
1 answer

Leetcode 208 about TRIE. What's wrong with my deconstructor? It never works

#include using std::string; class Trie { private: Trie* p[26]; bool end; void clear(Trie* pt) { for (int i = 0; i < 26; ++i) { if (pt->p[i]) { clear(pt->p[i]); …
Tarse
  • 1
  • 1
-1
votes
1 answer

Create a Trie from an array of strings using in swift with certain Constraint

create a Trie from an array of strings using in swift The concept is : you have given an array of strings like : # The input will be always in the below format "x1>x2>x3...>xn=Integer" else it is invalid input # private let input = [ …
Ashis Laha
  • 2,176
  • 3
  • 16
  • 17
-1
votes
1 answer

Printing from Trie

I have built a trie in C++ designed to hold words of sentences. Each sentence will have a weight which determines the order in which they should be output. I have several recursive functions that call other recursive functions, and the dilemma I am…
Dak
  • 1
-1
votes
1 answer

Pset5 implementation of Load using trie

I'm having some trouble in the pset5, I actually don't know how to start debugging, I've watched the lessons a few times now and I'm not getting anywhere.. When I run speller.c it is giving me a seg fault, I ran the debugger and it crashes at the…
-1
votes
1 answer

How to save/load a trie created in c# WPF

I made a WPF application that uses a trie (based on this one) to store a polish dictionary (37.9MB). Creating it from the dictionary.txt takes too much time (30 seconds on my laptop). I thought that maybe if I created some kind of binary file with a…
Jecke
  • 239
  • 2
  • 13
-1
votes
1 answer

checking apostrophe in trie data structure

I have a dictionary file(containing words only lower case and apostrophe) that is loaded as a trie tree. I have a check function which checks the words of file if they exist in the trie tree, regardless of letters cases. Everything works fine except…
Yasser Altamimi
  • 429
  • 5
  • 13
-1
votes
2 answers

Java Tries : Need a better approach

I am new to tries and testing how it works. Right now I am building a contact list. I add 'Prashanth' and 'Pradep' to the trie and when I search 'Pra' I should receive the count as two. My approach is having the variable size in each node and…
Krishnakanth Jc
  • 183
  • 1
  • 14
-1
votes
1 answer

Maximum XOR-Subarray

this question was asked in acm-icpc in 2009. I have solution in java but why i am getting wrong answer.Please help me in find out the error. Is trie construction is fine and to find maximum with trie is right. i am trying it first time Problem…
-1
votes
2 answers

Can't understand tries in C

I'm starting to work with tries in C and I made this really simple program, but somehow it crashes. I don't know why but if you could take a look at my code and tell me that would be great. #include #include #include…
-1
votes
1 answer

Can a patricia trie contain duplicate keys

More specifically can a patricia trie: http://search.cpan.org/~plonka/Net-Patricia-1.014/Patricia.pm Contain duplicate IP addresses (duplicate key IP with different values) and if so how does it handles returning the values from that…
north.mister
  • 500
  • 1
  • 7
  • 24
-1
votes
1 answer

C trie trying to add apostrophe

I'm trying to program a trie in C to read a file and add all the words in the file to the trie, and it works well, but I can't get it to accept apostrophes: typedef struct node { bool wordBool; struct node* next[27]; // 26 letters and one…
MLShax
  • 13
  • 6