Search code examples
stringdata-structuresmatchingprefixtrie

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?


Solution

  • .retteb era seirt xiferp ,drawkcab daer uoy fI

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