# Trie search algorithm

**URL:** <https://www.ruby-forum.com/t/trie-search-algorithm/140422>\
**Category:** Ruby\
**Created:** [June 13, 2008, 7:43pm UTC](https://www.ruby-forum.com/t/trie-search-algorithm/140422 "2008-06-13T19:43:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jturney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jturney](https://www.ruby-forum.com/u/jturney)\
**Post date:** [June 13, 2008, 7:43pm UTC](https://www.ruby-forum.com/t/trie-search-algorithm/140422/1 "2008-06-13T19:43:12Z")

</div>

I’m lost–can’t figure out the algorithm to output a trie.

class Trie  
@value  
@children = [] # array of tries  
@number\_exists # bool  
end

```
     0 # Root = nil
    /
   1 => number_exists = true(#1)
  /
 1 => number_exists = true(#11)
/ => 1 => true(#111)

```

/ =\> 2 =\> true(#1112)  
/ =\> 2 =\> true(#112)  
/ =\> 5 =\> true(#1125)  
0 =\> number\_exists = true(#110)

Any help is much appreciated, thanks!

Justin
