Looking for a good introduction on trie [closed]
Asked Answered
S

5

6

I am looking for a good introduction/tutorial on Tries.
Most of the links I find googling are either too succint and abstract for me or too trivial.
Could someone please provide a good reference with examples in Java for me to study?

Thanks

Slugabed answered 21/5, 2012 at 11:45 Comment(3)
Related: #624392Severson
I am not looking for an implementation to use.I want to study the conceptSlugabed
@Slugabed Did you find an acceptable answer?Demonstration
D
1

I've recently coded up a Trie and Patricia Trie in Java. They are written to be easy to follow. All the data structures were built from their Wikipedia descriptions.

Related classes: Radix Trie, Suffix Trie, Trie Map.

If you have any questions, feel free to ask.

Demonstration answered 21/5, 2012 at 12:41 Comment(8)
Thank you. I will read this. Do you have some reference for background info on trie?Slugabed
I mostly used Wikipedia's description and pictures. There was another site I used, I'll see if I can find it.Demonstration
I am looking into your code.I was wondering it does not create a full tree right?Slugabed
I'm not sure I know what you mean by full tree. It creates a node for each unique letter in each string.Demonstration
A trie is a prefix tree, so all strings inputted into the trie with a common prefix would share the same nodes off the root. If the trie has two strings named bat and bag inputted. The root would have one node hanging off with the value 'b' which has a single child with a value of 'a'. The 'a' node would have two children with values 't' and 'g'.Demonstration
I was perhaps confused as I am also reading about suffix trees.They are compressed sufix tries?Slugabed
Also how come you used CharSequence?Slugabed
I used CharSequence, so the Trie can represent a CharBuffer, String, or StringBuffer, not just limited to String.Demonstration
L
2

Googling found this blog with a series of articles in Java.

But I'd recommend buying a text book. Lots of Java oriented books on Data Structures and Algorithms are available from your favourite online bookstore.

Lillith answered 21/5, 2012 at 12:4 Comment(4)
I'll read your link. Also do you have a recomendation of textbook that dedicates a section specifically on Trie?Slugabed
@Slugabed - no I don't. But some online bookstores allow you to view the table of contents of text books ...Lillith
Actually the blog you linked to is quite good! +1 from meSlugabed
+1 from my side as well....it really is a good source:)Swaddle
E
1

Sure, have a look at Steve Hanov's site, like Fast and Easy Levenshtein distance using a Trie.

Excommunication answered 21/5, 2012 at 11:49 Comment(2)
Thank you, but the link is about using a Trie to improve on Levenstein and it assumes you know what a Trie is, more or less, and it is in Python, which I don't know at allSlugabed
help yourself... reading that article tells you everything you need to know about what's a trie and how it worksExcommunication
D
1

I've recently coded up a Trie and Patricia Trie in Java. They are written to be easy to follow. All the data structures were built from their Wikipedia descriptions.

Related classes: Radix Trie, Suffix Trie, Trie Map.

If you have any questions, feel free to ask.

Demonstration answered 21/5, 2012 at 12:41 Comment(8)
Thank you. I will read this. Do you have some reference for background info on trie?Slugabed
I mostly used Wikipedia's description and pictures. There was another site I used, I'll see if I can find it.Demonstration
I am looking into your code.I was wondering it does not create a full tree right?Slugabed
I'm not sure I know what you mean by full tree. It creates a node for each unique letter in each string.Demonstration
A trie is a prefix tree, so all strings inputted into the trie with a common prefix would share the same nodes off the root. If the trie has two strings named bat and bag inputted. The root would have one node hanging off with the value 'b' which has a single child with a value of 'a'. The 'a' node would have two children with values 't' and 'g'.Demonstration
I was perhaps confused as I am also reading about suffix trees.They are compressed sufix tries?Slugabed
Also how come you used CharSequence?Slugabed
I used CharSequence, so the Trie can represent a CharBuffer, String, or StringBuffer, not just limited to String.Demonstration
O
0

I recommend Stefan Nilsson's Ph.D. thesis from 1996, Radix Sorting & Searching (The searching part is what you are looking for.) It is quite an easy read for a research publication and contains a lot of both theory and practice about tries.

The examples are in C, not Java, but you shouldn't have much trouble understanding them if you know Java.

Orthogenetic answered 21/5, 2012 at 12:40 Comment(0)
N
0

Found this topcoder link on trie quite useful :

http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=usingTries

Nonu answered 6/8, 2013 at 12:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.