DEV Community

Discussion on: A Visual Guide to How to Actually Invert a Binary Tree

Collapse
 
jacobjzhang profile image
Jake Z.

Great takeaways! I totally agree with the first two points. Do you mind expanding on "you don't need to swap the branch labels", particularly which labels we're talking about?

Collapse
 
pentacular profile image
pentacular • Edited

You have two branches -- say 'left' and 'right'.

Instead of modifying the tree you can modify how you traverse it.

Where you would choose 'left', instead choose 'right'.
Where you would choose 'right', instead choose 'left'.

Thread Thread
 
jacobjzhang profile image
Jake Z.

Ah gotcha, yes!