Skip to content

Instantly share code, notes, and snippets.

@airekans
Created June 11, 2015 09:42
Show Gist options
  • Save airekans/9a8d54e1bfdfb0f52ab2 to your computer and use it in GitHub Desktop.
Save airekans/9a8d54e1bfdfb0f52ab2 to your computer and use it in GitHub Desktop.
二叉树反转
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