What is a time complexity for inserting an alphabet in the tree using hash maps?

(a) O (log n!)

(b) O (n!)

(c) O (n^2)

(d) O (1)

The origin of the question is Suffix tree topic in chapter Trie of Data Structures & Algorithms I

This question was addressed to me during an interview.

1 Answers

The correct choice is (d) O (1)

Best explanation: Suffix tree is also known as PAT tree or position tree. It allows fast string operation. Total time taken for construction of suffix tree is linear to the length of the tree. The time complexity for inserting an alphabet in the tree using hash maps is constant, O (1).