I know a similar question has been asked (Prefix vs Suffix Trie in String Matching) but the accepted answer did not help me understand my query. The question is: What advantage does a suffix trie have over a prefix trie ?
Asked
Active
Viewed 1,108 times
2 Answers
0
Suffix tries allows you to choose the beginning of the string and look how long they match. It is probably similar to accepted answer on the original question but that's the best I can do.

Murat Akburak
- 51
- 1
- 1
- 12
-
1A prefix trie can also do that. Why a suffix trie then ? – random40154443 Nov 14 '15 at 10:24
-
Adding all prefixes of a string will produce a trie like just one path and it is the string's itself. How can you run a string matching algorithm over that trie ? – Murat Akburak Nov 14 '15 at 10:28
-
If you are talking about adding prefixes reversed order and look for string's reversed order prefix trie works but it is the same as suffix trie and the normal order is the way how it is :D Why do you reverse it ? – Murat Akburak Nov 14 '15 at 10:32
-
I guess substring matching won't work in a prefix trie because every prefix substring will start with the same characters. Is that one of the reasons ? – random40154443 Nov 14 '15 at 10:37
-
Yeah exactly it is . – Murat Akburak Nov 14 '15 at 12:14
0
You can try look at aho-corasick algorithm. It is a finite state machine and basically it uses a special prefix trie with failure links from the prefixes to the first occurence of the longest suffices in the trie. Basically it is a breadth-first search of the trie. AC is used in fast multiple pattern matching.

Micromega
- 12,486
- 7
- 35
- 72