top of page

How to Reverse (or mirror) a Binary Tree in C#




Reversing a binary tree is so easy that even Joe Rogan can do it!


It's one of those questions that is asked a lot in a job interview because senior developers want to see how you work your way through the problem.


Just follow the algorithm: RE-BESIE.

RE - Write the REverse Method

B - If both the left node and right node are null, return.

E - Else

S - Swap the nodes

I - If the left node is not null, send the left node to reverse.

E - Else - Send the right node to reverse


And that's it! That's all you have to do. The code for this can be found at:

Comments


Archive
Search By Tags
Follow Us
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square
© 2024 by Ryan McBeth
  • Instagram
  • ba81cfff-7bc5-4aef-866e-864d0942c42d_1000x1000
  • concours-discord-cartes-voeux-fortnite-france-6
  • YouTube
  • LinkedIn
  • Twitter Social Icon
bottom of page