Back to Browse

Reverse a binary tree in C# for a job interview (Updated)

7.2K views
Sep 11, 2021
15:13

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-BESII. 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. I - If the right node is not null, 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: https://github.com/mcbethr/ReverseABinaryTree or ryanmcbeth.com

Download

1 formats

Video Formats

360pmp446.9 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

Reverse a binary tree in C# for a job interview (Updated) | NatokHD