invert a binary tree
//The Idea is to go through a post order traversal and swap the node at the end //assume TreeNode is the tree structure TreeNode* invertTree(TreeNode* root) { if(root==NULL) return root; else { invertTree(root->left); //assuming the fn did inverted everything till of left child invertTree(root->right); //assuming the fn inverted everything till of right child //now swap the left child and right child nodes and return the node TreeNode* temp=root->left; root->left=root->right; root->right=temp; return(root); //return the inverted node } }