String data structures Flashcards

1
Q

Trie (idea)

A

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).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Pattern searching algorithms (name and runtime) T- text, P- patterns

A

Naive - 𝑂(|𝑇|βˆ™|𝑃|)
KMP - 𝑂(|𝑇|+|𝑃|)
Boyer & Moor - 𝑂(|𝑇|+|𝑃|)
Karp & Rabin - 𝑂(|𝑇|+|𝑃|)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Suffix tree (idea, time, space)

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Suffix tree space complexity improvement (how)

A

Combine all nodes that don’t lead to an index together, leading to O(T) space complexity.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly