Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prefix vs Suffix Trie in String Matching

I'm not too well-versed about the actual algorithms used in string matching with tries.

I'm wondering why there seems to be more focus on suffix tries for string matching rather than prefix tries. Can we not use prefix tries for substring matching also? Put in another way, what are the advantages of suffix tries over prefix tries?

like image 685
Mike Avatar asked Jul 14 '11 11:07

Mike


People also ask

What is the difference between suffix trie and suffix tree?

The trie is used to build the suffix tree and that is why most textbooks only provide code for tries. But this is the worst-case implementation eh? @Cratylus Suffix trees are most useful on very large strings (eg. indexing all the works of Shakespeare) where O(n^2) space and build time is simply not going to cut it.

Where should we use suffix arrays instead of suffix trees?

The suffix tree is lighter and faster than the trie and is used to index DNA or optimize some large web search engines. The suffix array is slower in some pattern searches than the suffix tree but uses less space, and is more widely used than the Suffix tree.

How trie data structure makes patterns match faster?

The trie data structure provides fast pattern matching for string data values. Using trie, we bring the search complexity of a string to the optimal limit. A trie searches a string in O(m) time complexity, where m is the length of the string. In trie, every node except the root stores a character value.

What is suffix trie used for?

Trie. In a trie, each alphabet of all the strings in the prescribed string is parsed one by one and represented by a single node. If two or more words start with the same sub-string, the identical sub-string is represented by the same chain of nodes.


1 Answers

.retteb era seirt xiferp ,drawkcab daer uoy fI

Seriously. Suffix tries allow you to traverse from the beginning of a string.

like image 164
Ed Staub Avatar answered Oct 18 '22 13:10

Ed Staub