FAQ Database Discussion Community


Finding the longest word from a digital tree (trie) in C++

c++,search,tree,trie
For an assignment, I had to make two methods, one prints out a digital tree storing a few words and marks a * next to an actual word. The other method is supposed to find the longest word in this digital tree. Here is the defined class (with my completed...

Is there an alphabetic wchar_t such that its capital and lower versions are the same?

c,trie,wchar-t
I've been wondering whether there is a char c such that iwalpha(c) == 1 and towlower(c) == towupper(c). I'm trying to implement a dictionary in a trie. Each node has a wchar_t label and a boolean a_word which provides us with the information whether the node represents a word. I'd...

Trie - Implementation in java

java,trie
I know there is plenty of material available regarding it but i had quite specific questions. I have a file containing postal codes and i have to create trie data structure using those codes. I have written my implementation which is - public class Trie{ TrieNode root = null; public...

Java: make prefix tree remember last value that was not null

java,tree,prefix,trie
I have code for prefix tree (Trie) like this: public class Trie<V> { Entry<V> entry; char key; Map<Character, Trie<V>> childrens; public Trie() { this.childrens = new HashMap<Character, Trie<V>>(10); entry = new Entry<V>(); } /** non-public, used by _put() */ Trie(char key) { this.childrens = new HashMap<Character, Trie<V>>(10); this.key = key;...

What is the most efficient way to find out which subnet an IP belongs to

algorithm,scala,data-structures,ip-address,trie
Suppose I have billions of records that contain IPv4 field each. And I want to find out: If each record belongs to one of the subnet I concerns Which subnet it belongs to if it satisfies requirement 1. Each concerned subnet is defined as several masks(61.232.85.0/25, 61.232.86.0/27) and maybe some...

How to scale a trie across multiple servers

architecture,system,scalability,distributed-computing,trie
Does anyone know how I might scale a Trie across multiple machines? Say the first machine runs out of space and I need to add more words from a very large dictionary, what might I do to add more words? (I am a Java thinker, but I believe the answer...

Get Words out of a Trie Data Structure

java,search,trie
i have the following Trie Data Structure: public class CDictionary implements IDictionary { private static final int N = 'z' -'a'+1; private static class Node { private boolean end = false; private Node[] next = new Node[N]; } private int size = 0; private Node root = new Node(); @Override...

Python Trie implementation why create temporary variable [closed]

python,algorithm,data-structures,implementation,trie
I looked at this code: >>> _end = '_end_' >>> >>> def make_trie(*words): ... root = dict() ... for word in words: ... current_dict = root ... for letter in word: ... current_dict = current_dict.setdefault(letter, {}) ... current_dict = current_dict.setdefault(_end, _end) ... return root ... >>> make_trie('foo', 'bar', 'baz', 'barz')...

how can an objects points on many other objects in JAVA?

java,pointers,tree,trie
I'm trying to build a TRIE, but for that I need that the root of the tree would be able to point on sons as much as I want to create (since it's supposed to use as Prefix tree). So I'd like to know if it is even possible make...

Couldn't import class to Java project

java,dependencies,trie
I am trying to import import org.apache.commons.collections4.trie.PatriciaTrie; It gives me error that it does not exists. I am using Lucene with Glassfish server. What should be done to fix that issue?...

Trie Data Structure in Finding an Optimal Solution

java,algorithm,data-structures,tree,trie
This Question is part of ongoing Competition , I have solved the 75% of this Question Data Set but the 25% is giving me TLE. I am asking why it's is giving TLE an i am sure my complexity is O(n*n)Question: String S consisting of N lowercase English alphabets. We...

Retrieving a lost string from a trie

algorithm,data-structures,trie
On exam on data structures I did see the following question: A suffix trie is given. Now I know that that a trie only holds pointers with specific indexes to an array of chars. Now they claim that the original string is lost, and I should find the string only...