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