Created
September 22, 2015 12:26
-
-
Save ericchiang/7fffce1c7faf72e53f24 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tree | |
type BinaryTree struct { | |
Val interface{} | |
LeftChild, RightChild *BinaryTree | |
} | |
func (b *BinaryTree) Invert() { | |
if b == nil { | |
return | |
} | |
b.LeftChild.Invert() | |
b.RightChild.Invert() | |
b.LeftChild, b.RightChild = b.RightChild, b.LeftChild | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment