String Algorithms Flashcards

1
Q

What is the time complexity of checking if a string is a palindrome?

A

O(n)

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

What is the KMP algorithm used for?

A

Pattern matching in O(n + m) time.

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

What is the Rabin-Karp algorithm?

A

Uses hashing for fast pattern search.

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

What is the Boyer-Moore algorithm used for?

A

Skips unnecessary comparisons in pattern matching.

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

What is the longest palindromic substring problem, and how is it solved efficiently?

A

Solved with dynamic programming or Manacher’s algorithm.

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

How can a Trie be used for efficient string matching?

A

Stores words for efficient prefix searches.

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