DSA GRIND #9

 INVERTING A BINARY TREE - AB 


This weeks problem is similar to our earlier work on reversing a linked list data structure, but in this instance we're going to be inverting a binary tree. The following picture shows an example of what that means.

Like our earlier work, I went about doing this recursively as well. So kept making calls back to the function within itself as we went about inverting the data structure node for node. The results/code is as follows. 


The code was solid, though the memory management was pretty lacking, its resource intensive holding the same calls within the stack for execution. 

Comments

Popular posts from this blog

IP #6 : Reversing an Integer