This question evaluates understanding of binary tree manipulation and traversal methods, emphasizing recursion and iterative approaches as well as the ability to reason about time and space complexity.
Given the root of a binary tree, convert it to its mirror by swapping every node’s left and right children. Implement both recursive and iterative (using a stack or queue) solutions, analyze time and space complexity, and discuss edge cases (empty tree, single node, highly unbalanced). Perform a dry run on this tree (level order): [5,3,8,null,4,7,9].