Join us in building a kind, collaborative learning community via our updatedCode of Conduct.

Questions tagged [trie]

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

0
votes
0answers
26 views

LevelDB and trie like structures saved in them traversal enhancement

Currently I am working on implementing the Modified PatriciaTree into a Java Implementation. I have found the ethereum implementation here: https://github.com/ethereumj/ethereumj/tree/master/ethereumj-...
0
votes
1answer
22 views

CS50 Pset5 check() counting too many words as misspelled

I have loaded the dictionary into a tree structure and successfully gotten speller.c to compile with the following implementations of load() and check().However, when I run the program, an incorrect ...
0
votes
0answers
30 views

Converting a Trie into JSON format

I'm planning to implement autocomplete feature using trie data structure. I want to convert my trie into a JSON format.class Trie(object):"""Class representing the structure of trie"""def ...
4
votes
1answer
134 views

How to find all words on the Boggle board using Dynamic Programming?

I enrolled in the Algorithms, Part II course on Coursera, and one of the assignments is to solve the Boggle game:http://coursera.cs.princeton.edu/algs4/assignments/boggle.htmlThe honor code ...
1
vote
0answers
65 views

How to convert a string path to a tree (hierarchial path)

I am trying to insert a string path into a trie data structure, But I am not able to make relation between child and root. it looks like I am not insertingelement into proper way into trie.For ex. /...
0
votes
1answer
13 views

Storing the same words with one extra letter in a trie (example: bull and bully)

How can we store words like (bull and bully) and (bid and bide) in the same trie? If there is a leaf node at the 'y' in bully, is bull still stored on the same branch? Or will there be two branches ...
-2
votes
1answer
46 views

Using Capital letters and small letters to implement Autocomplete in Java

Design an autocomplete function for IDE. Given the String[] below, some capital letters and small letters are included in the input. We are asked to implement the autocomplete, and all capital letters ...
0
votes
1answer
49 views

Elastic search or Trie for search/autocomplete?

My understanding how autocomplete/search for text/item works at high level in any scalable product like Amazon eCommerce/Google at high level was :-Elastic Search(ES) based approachDocuments are ...
0
votes
0answers
31 views

Why do I need to allocate memory before moving the pointer in a TRIE data structure in C

In this program I try to load a dictionary into TRIE data structure. The first excerpt of code worked as I expected. But the second excerpt of code, in which I tried to optimize the code to make it ...
10
votes
1answer
218 views

How Immutability is Implemented

I am trying to grasp how the trie and such in immutability is implemented, as relates to immutability in JS. I understand how there is supposed to be significant structural sharing.My question is ...
0
votes
1answer
51 views

Data structure for efficient string matching against many patterns

I am looking for an efficient data structure that allows string to pattern matching. The patterns follow a regex like syntax but allow recursion. They contain optionals, choices and recursion/wildcard ...
1
vote
1answer
24 views

Passing Trie tree node as parameter - not working

I'm trying to implement a function that reads all words contained in a Trie tree, stores them in a list with their keys and writes them in a .csv file. The function 'insertTrie' works fine; however, ...
0
votes
1answer
45 views

Prefix-tree for pairs of elements

I have a nested list:lists=[['a', 'b', 'c', 'd'],['a', 'b', 'd', 'e'],['a', 'b', 'd', 'f'],['a', 'b', 'd', 'f', 'h', 'i']]I know how to build a simple prefix-tree:...
-1
votes
1answer
24 views

How To Create A URL Tree

I have an array of URLs that look like this:$arr=['/foo'=> 'callback','/foo/bar'=> 'callback','/foo/bar/baz'=> 'callback','/bar/baz'=> 'callback',];I want to ...
0
votes
1answer
22 views

Implementation of trie with map without creating new nodes

I was trying to implement the trie data structure & wrote the foll code#include<iostream>#include<string>#include<map>#include<vector>using namespace std;struct ...
0
votes
1answer
24 views

Having a error in Trie implementation (Javascript)

I'm implementing the add function of Trie Algorithm but it is giving me the following error:Uncaught TypeError: node is not a constructor...in this code line:node.children[char_pos]=new Array(...
0
votes
1answer
72 views

C trie memory leak in add function

I've been trying to get my code to work. It compiles but when I run it I get a segfault and gdb and valgrind pointed to this line in particular and my problem is that I don't really know how to fix it:...
0
votes
0answers
38 views

Empty Declaration with Storage class specifier/Two or more data types in declaration specifiers

I'm currently getting 2 errors when I try to compile my files with a makefile.The following errors pop up and I'm not sure how to fix it:two or more data types in declaration specifiersempty ...
0
votes
0answers
73 views

Recursive deletion of trie in c

I've been trying to delete a trie recursively. The typedef of the trie is as follows:typedef struct _trie{bool word;struct _trie *link[27];}trie;The recursive code for deletion is as follows, ...
0
votes
0answers
12 views

Trie/Decision Tree for Conditions/Queries

I have set of queries and I get an Object at a time and I want to figure out the object satisfies which of the queries.For example the queries look like1) Customers with Age > 25 and NetWorth >=...
1
vote
0answers
29 views

C++ Integer Trie implementation using a hash_map to reduce memory consumption

I have to implement a Trie of codes of a given fixed-length. Each code is a sequence of integers and considering that some patterns are usual, I decided to implement a Trie in order to store all the ...
0
votes
0answers
34 views

When to avoid Trie for Dictionary related problems

Fellow programmers, need your advice while going through this question on HackerRank: Password Cracker I tried this question with a Trie, as it seemed like the first and best approach to me for ...
1
vote
0answers
26 views

Python: how to speed up this method of exhaustion? Trie?

I have a corpus with lines of sentences without spaces between words:thenextdayonmayanarchistsstagedarallyatchicagoshaymarketsquare...
1
vote
0answers
24 views

Sentence Trie/Tree/dictionary/corpus

I am hoping to build a tree in which a node is an English word and a branch of leaves form a sentence. Namely,a sentence tree (plz ignore the numbers):I was thinking to use a Trie but I am having ...
1
vote
1answer
25 views

Trie data structure timecomplexity

Assuming that the strings to be stored in a Trie are 'n' number of characters long. What would be the execution time for insert(), search() and remove() ?I have looked on the internet, but I didn't ...
0
votes
1answer
24 views

What indicates if a string exists or not in a trie

Every video or explaination in books are not clear or agree if the ending point of a word/string, has a special key that is returned or a boolean true is returned. e.g. We know that the trie has the ...
-3
votes
1answer
55 views

Palindrome Pairs

Given a list of unique words, find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two words, i.e. words[i] + words[j] is a palindrome.Example 1:Given words ...
-2
votes
2answers
55 views

Counting leaf node in a trie

I want to count how many leaf node in a trie structure by counting how many words there are in the trie, but my code is not updating the counting value, instead it always reset back to 0.int num=0;...
0
votes
1answer
64 views

Issue searching through a Trie

I have written a code that implements Trie data structure where it takes in a list of strings and the string's count. lst=[['james',9],['chloe',20],['chlara',30]]The strings are the names, and ...
1
vote
2answers
104 views

Return strings that matches the prefix in a Trie

I managed to construct a Trie and now i want to return strings that matches a prefix from the Trie but I'm having issues writing the search function.For example, if i have a prefix "aa", i want to ...

153050per page
angop.ao, elkhabar.com, noa.al, afghanpaper.com, bbc.com, time.com, cdc.gov, nih.gov, xnxx.com, github.com,