🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: Tree Traversals: questions with answers

13 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. For the tree with root 10, left child 5 and right child 20, what is the postorder?
  2. Q2. Which traversal of a binary search tree gives the values in sorted order?
  3. Q3. What does this print? (code)
  4. Q4. What extra space does a recursive traversal use on a tree of height h?
  5. Q5. Computing the height of every node from its children's heights is which kind of traversal?
  6. Q6. In iterative preorder with a stack, why is the right child pushed before the left?
  7. Q7. "Return the last node of every level" (right side view) is easiest with:
  8. Q8. What is the time complexity of any of the four traversals on n nodes?
  9. Q9. What does this print? (code)
  10. Q10. Which data structure does level-order traversal use?
  11. Q11. What does this print? (code)
  12. Q12. You want to copy a tree, creating each parent before its children. Which order visits nodes that way?
  13. Q13. To free (delete) every node of a tree safely, which order should you use?