Note that there are some explanatory texts on larger screens.

plurals
  1. POrecursive word trie traversal
    text
    copied!<p>I've found the same question here <a href="https://stackoverflow.com/questions/6041142/traversing-a-trie-to-get-all-words">Traversing a trie to get all words</a> , but it's for Perl, and I'm familiar only with Java. my trie structure is the plain integer array, where the first 26 ints are the roots, each integer has firstChild index which is child array element's index (up to 25 highest bits), End-of-List bit flag, End-of-Word bit flag, letter index from 1 to 26(lowest 5 bits). I can recursively print one word <code>CAGE</code> if I pass the 2(root index for letter c) as a parameter</p> <pre><code>private void oneWord(int node) { System.out.print(getChar(Trie[node])); if (getEOL(Trie[node]) != 1) { oneWord(getFirstChild(Trie[node])); } } </code></pre> <p>or a common beginning and distinct endings like <code>YARDELLOW</code> for words yard and yellow(passing 24 as parameter)</p> <pre><code>private void DFTSearch(int node) { System.out.print(getChar(Trie[node])); if (getFirstChild(Trie[node]) != 0) { for (int i = 0; i &lt; getSiblingsNum((getFirstChild(Trie[node])); i++) { DFTSearch(getFirstChild(Trie[node]) + i); } } } </code></pre> <p>but can't do that with all words(( and I've tried this and that to make it return a string, and haven't got any success(just was getting a very first letter of a string. Please help with the method to print recursively(and what is better - return String array) for all words from my trie. It's not a homework, I'm self-educating))</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload