String data structures Flashcards
Trie (idea)
Store all strings in a tree, each node has k (number of different letters in language) pointers to the next letter in the word, each word ends by pointing to a special node ($ for example).
Pattern searching algorithms (name and runtime) T- text, P- patterns
Naive - π(|π|β|π|)
KMP - π(|π|+|π|)
Boyer & Moor - π(|π|+|π|)
Karp & Rabin - π(|π|+|π|)
Suffix tree (idea, time, space)
A Trie tree that includes all of the suffixes of the inserted words, each suffix pointing to the index. Enables Searching for patterns in O(P) time. O(T^2) space.
Suffix tree space complexity improvement (how)
Combine all nodes that donβt lead to an index together, leading to O(T) space complexity.