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

Reading From a file in android that is private to the Application

I am developing an android application and i need to read words from a file to create a Trie. Is there a way i can write the file to internal storage on install so that only my application can access it, or should i hard code the words. Any…
Darussian
  • 1,573
  • 1
  • 16
  • 28
-2
votes
1 answer

Maximum XOR with all possible subsets of an array with a specific integer

Given an array of integers P = [P1, P2, ...] and a function F(M) that returns the XOR of all integers present in set M. If M is empty, then F(M) = 0. The task is to find the maximum possible value of the expression N XOR F(M) over all possible…
-2
votes
1 answer

Design In-Memory File System - Python - Trie - Leetcode Error

I am trying to solve the below leetcode problem Design a data structure that simulates an in-memory file system. Implement the FileSystem class: FileSystem() Initializes the object of the system. List ls(String path) If path is a file path, returns…
-2
votes
1 answer

Using custom recursive data type in haskell -> TRIE

I am learning Haskell and I just got a problem that seems to be quite hard. I have a custom recursive data type for Trie. data Trie keytype valuetype = TNode (Maybe valuetype) [Edge keytype valuetype] deriving (Show, Eq) type Edge e a =…
-2
votes
1 answer

when using a trie i get an unusual error that shouldnt be possible

I am working on a simple spell checker which grabs the alphabet from a text file and then checks any word for whether it is a correct spelling or not using a trie Code import java.io.BufferedReader; import java.io.FileReader; import…
danCodes
  • 23
  • 6
-2
votes
1 answer

Which data structure is used to implement a trie?

Which data structures should I use to implement a trie in Java? Do I use a linked list, array, map?
deepeshdm
  • 43
  • 4
-2
votes
1 answer

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 must be matched. ex: String[] className { …
-2
votes
2 answers

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; public int countLeafNodes() { for (char c :…
thiuye
  • 1
  • 1
-2
votes
1 answer

How to optimize this kind of code

How could i get the mark and mary by using searchstring and current_object? I have to use array_push for pushing new searchstring and current_object for create new output like mark and mary. function get_suggestion_array_from_object(searchstring,…
rai
  • 27
  • 1
  • 7
-2
votes
1 answer

Printing Contents and Count of Trie in C

I am working on code that will print out the words contained in a trie and note the amount of times that the word occurred. I thought the most effective way would be for a letter to be stored in the element of the relevant node when a word is added…
Brooklyn
  • 17
  • 1
  • 7
-2
votes
1 answer

How to define class for Trie in cpp

Hi I am new to oops in cpp. I define a class for trie Node as follows. But I get this error and I couldnot find where I am wrong. Thanks in advance. Error : Line 5: expected identifier before numeric constant class Node { public: …
danish sodhi
  • 1,793
  • 4
  • 21
  • 31
-2
votes
1 answer

cs50 pset5 dictionary.c : this code is giving segmentation fault

i have written this code for pset5 dictionary.c i loaded dictionary in trie data structure. it shows segmentation fault. /** * Implements a dictionary's functionality. */ #include #include #include
-2
votes
1 answer

Loading a trie data structure in C- pset5 cs50

I am having trouble loading data into my trie structure. I keep getting a sgemenation fault. Does this have to do with my malloc? Anyone see any issues? Thanks /** * dictionary.c * * Computer Science 50 * Problem Set 5 * * Implements a…
menan
  • 195
  • 1
  • 1
  • 8
-2
votes
1 answer

Create a trie in perl

Objective is to create a trie data structure. I had seen Tree::Trie and used it. It converts data into trie structure only after the file(database) is read. So this will make processing slow as each time a lookup is needed entire data is converted…
Nagaraju
  • 1,853
  • 2
  • 27
  • 46
-2
votes
1 answer

Simple C trie program goes wrong (segmentation fault)

In order to understand tries I am creating this very simple C program that takes from user 10 nums from 0 to 9 as children of the trie. The final step is to print this nums with the function print, but I am getting a segmentation fault: #include…
Spyreto
  • 29
  • 5