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
-2
votes
1 answer

Data Structure - Trie C++, issue inserting words. Access violation reading location

I am coding a dictionary Trie as an assigment, C++ . I keep getting an error when inserting certain letters in words, especially 'l' and 't' if they are not the first letter. This is the error Unhandled exception at 0x00EC5392 in A4Tries.exe:…
-2
votes
1 answer

Need to add words in a Trie

Can any one help me how to add word in a Trie really new to data structure /** * This method adds a word to the Trie * * @param s - word to add to the Trie * @param data - Data associated with word s */ public void addWord(String s, E data)…
CLearner
  • 63
  • 1
  • 2
  • 8
-2
votes
1 answer

Trie data structure on dictionary to find rhyming words

I'm working on my function that would find rhyming words from my dictionary text file that contains 40,000 words. For an example, I enter akes and it gives the words printed would be "rakes sakes takes". So, I know it requires data structure with…
Cam9191
  • 33
  • 8
-2
votes
1 answer

Search Trie implementation

I have written a code StringTrie.java implemented through interface Trie.java: package il.ac.tau.cs.sw1.trie; import java.util.Set; /** * Represents a generic trie data structure, where K is the type of keys that * are saved in the trie, and V is…
Rotemk55
  • 43
  • 7
-2
votes
1 answer

Java - Deleting word in trie (pseudo code please)

I've been working on trying to plan out how to delete words from a trie. I have an implementation that uses a one-dimensional array on the node which holds the next characters for a word. I understand how I can get rid of a whole word but not…
user3362954
  • 1,221
  • 2
  • 15
  • 23
-3
votes
1 answer

Haskell trie functions - Inserting values and searching

The type of the trie is data Trie a = TrieNode (Maybe a) [(Char, Trie a)] deriving Show I want to write a function that takes in a key-value pair and a prefix trie. I then want it to return the symbol table where the key-value pair is included. If…
Oakin
  • 143
  • 2
  • 15
-3
votes
1 answer

How do I implement code to search word in a Trie?

Code: Search word in Trie Implement the function SearchWord for the Trie class. For a Trie, write the function for searching a word. Return true if the word is found successfully, otherwise return false. Note: main function is given for your…
-3
votes
1 answer

c++ "error: invalid use of void expression"

I'm trying to implement a trie and I get the following error: error: invalid use of void expression 5 | collect(node->next[c], pre.push_back(c), q); | ^~~~~~~ This is my function: void string_map::collect(Node* node, string pre,…
-3
votes
1 answer

How to check if a word can be composed of entries in an array?

I have the following task: A word "Superhighway" is given. Check if such word can be composed of entries in the array: [ab, bc, Super, h, igh, way] - yes; [ab, bc, Super, way] - no; My suggestion is to build Trie from the array and based on the…
Pasha
  • 1,768
  • 6
  • 22
  • 43
-3
votes
1 answer

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 = ["bat", "tab", "cat"] Return [[0, 1], [1,…
-3
votes
1 answer

Unload() recursion C Segfault (TRIE like data base) CS50 pset5

edit 1 As suggested by Jonathan Leffler I am now not using names starting with underscores and also deleted spaces around ->. ________________________________________________________________________________ I am getting a segfault when trying to…
-3
votes
1 answer

Why does the root change its data?

Here is are the three structures that I'm using and for instance when my program gets 'the' as the first word, it makes *rt->str = the. However when the next word is read, the key is equal to to the *rt->str and I don't understand why. I'm a c…
-3
votes
1 answer

Multibit Trie Implementation in C

I'm getting the error Segmentation Fault: 11, when I'm trying to compile my C code using gcc. The code is implementing multibit trie algorithm for ip lookup and is as follows: Sometimes the code does run, however most of the times it's ending up in…
Arjun Sehgal
  • 59
  • 1
  • 8
-3
votes
1 answer

why this C++ Trie implementation is showing odd behaviour?

I implemented this class to create a trie data structure. The function unsigned long Insert(string) //inserts the string in trie & return no of words in trie void PrintAllWords(); // prints all words in trie separated by space in dictionary…
Sumit
  • 35
  • 5
-3
votes
1 answer

suffix tree implementation issue

I am studying some Suffix tree implementation and here is one reference implementation, and question is how "indexes" (refer line 19) is used for class SuffixTreeNode? I am not sure if "indexes" is useful and I think probably we just need to keep…
Lin Ma
  • 9,739
  • 32
  • 105
  • 175
1 2 3
73
74