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

Category: QuestionsWhat is a time complexity for finding the total length of all string on all edges of a tree?
Editor">Editor Staff asked 5 months ago

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)

This is a very interesting question from Suffix tree topic in chapter Trie of Data Structures & Algorithms I

The question was posed to me by my college professor while I was bunking the class.

Editor">Editor Staff answered 5 months ago

Correct choice is (d) O (n^2)

The best I can explain: 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).

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17
Articles: 40702