Dsa
Binary Search Tree
Easy
Invert Binary Search Tree
Given a Binary Search Tree (BST), invert the tree (swap the left and right children of all nodes). The input comprises the serialized representation of the tree in level order, with null nodes represented by a '-1'. Output the tree in the same serialized format after inversion.
Input format:
- A single line containing integers separated by space: the level order traversal of the tree.
Output format:
- The serialized level order traversal of the inverted BST.
Example:
Input:
4 2 7 1 3 6 9
Output:
4 7 2 9 6 3 1
Key concepts
binary_search_treetree_inversionrecursive
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now