What is a time complexity for finding the total length of all string on all edges of a tree?

Giao Linh

New member
What is a time complexity for finding the total length of all string on all edges of a tree?
A. Ɵ (n)
B. Ɵ (n!)
C. Ɵ (1)
D. O (n$^{2}$)
 
Answer: d
Explanation: 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 total length of all string on all edges of a tree is O (n$^{2}$).
 

Tìm kiếm

Back
Top