Graph Theory37 sections · 1633 units
Open in Course

Quiz: Tree Inversion

Knowledge check

Check Your Understanding

To invert a binary tree, you swap every node's left and right children. What is the time complexity of the recursive approach?

  1. A.O(n)O(n) time, O(h)O(h) space, where hh is the tree height
  2. B.O(nlogn)O(n \log n) time, O(n)O(n) space
  3. C.O(n2)O(n^2) time, O(1)O(1) space
  4. D.O(n)O(n) time, O(n)O(n) space always
Start the roadmap to answer the quizzes and solve the challenges