Created
June 11, 2015 09:42
-
-
Save airekans/9a8d54e1bfdfb0f52ab2 to your computer and use it in GitHub Desktop.
二叉树反转
This file contains 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
struct Node | |
{ | |
int data; | |
Node* left; | |
NOde* right; | |
}; | |
void invert_binary_tree(Node* root) | |
{ | |
if (root == NULL) | |
{ | |
return; | |
} | |
invert_binary_tree(root->left); | |
invert_binary_tree(root->right); | |
std::swap(root->left, root->right); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment