Skip to content

Instantly share code, notes, and snippets.

@ericchiang
Created September 22, 2015 12:26
Show Gist options
  • Save ericchiang/7fffce1c7faf72e53f24 to your computer and use it in GitHub Desktop.
Save ericchiang/7fffce1c7faf72e53f24 to your computer and use it in GitHub Desktop.
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