359 views
1 votes
1 votes
Kevin is asked to write a single program to print the inorder, preorder, postorder and level order traversal of a binary tree having $n$ nodes. The best possible time complexity of this function is ___________
  1. $\Theta(n^3)$
  2. $\Theta(n)$
  3. $\Theta(n^2)$
  4. $\Theta(n\log n)$

1 Answer

Best answer
2 votes
2 votes
All the traversals can be done in $O(n)$ time. So, the total time complexity remains $O(n).$
selected by
Answer:

Related questions

1 votes
1 votes
1 answer
1
gatecse asked Aug 9, 2020
185 views
What is the value of the postfix expression $8 \ 7 \ 2 \ 4 \ + \ – \ *?$:
1 votes
1 votes
1 answer
2
gatecse asked Aug 9, 2020
278 views
The data structures most suitable to do an inorder and level order traversals of a binary tree respectively areStack and QueueQueue and StackStack and StackQueue and Queu...
1 votes
1 votes
1 answer
3
gatecse asked Aug 9, 2020
160 views
The prefix form of $A/B- (C * D * E)$ is?$-/* * ABCDE$$-/ABCD DE$$-/AB CDE$$-A/BC*DE*$