+1 vote
in Data Structures & Algorithms I by (110k points)
What is the time complexity for the initialization of top tree?

(a) O (n)

(b) O (n^2)

(c) O (log n)

(d) O (n!)

Question is taken from Binary Trees in section Binary Trees of Data Structures & Algorithms I

The question was asked during an interview for a job.

1 Answer

+1 vote
by (737k points)
selected by
Best answer
Right answer is (a) O (n)

Best explanation: Generally, trees have weight on its edges. Also there is one to one correspondence of the edges with the top trees. Therefore, top trees can be initialized in O (n) time.

Related questions

Welcome to TalkJarvis QnA, a question-answer community website for the people by the people. On TalkJarvis QnA you can ask your doubts, curiosity, questions and whatever going in your mind either related to studies or others. Experts and people from different fields will answer.