Question bank › Trees
Dsa Trees Easy

Inverted Tree

Given a binary tree, invert it. This means that for every node, its left and right children are swapped. You need to output the tree in level-order after inversion. Input format: - The first line contains an integer N, the number of nodes. - The next N lines contain the values of the nodes in a level-order traversal, where 'null' means no child. Output format: - The output should be a level-order traversal of the inverted tree. Example: Input: 5 1 2 3 null null 4 5 Output: 1 3 2 5 4

Key concepts

treesinversionrecursion

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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.