What is a time complexity for finding the longest prefix that is common between suffix in a string?

What is a time complexity for finding the longest prefix that is common between suffix in a string?
A. Ɵ (n)
B. Ɵ (n!)
C. Ɵ (1)
D. O (log n!)
 
Answer: c
Explanation: Suffix Tree allows fast string operation. To check if a substring is present in a string of a length of n, the time complexity for such operation is found to be O (n). The time complexity for finding the longest prefix that is common between suffix in a string is Ɵ (1).
 

Tìm kiếm

Back
Top