Iterative solution
void mirror(Node* node) {
// code here
if(node == NULL) return;
queue <Node *> q;
q.push(node);
while(!q.empty()) {
Node *cur = q.front();
q.pop();
swap(cur->left, cur->right);
if(cur->left) q.push(cur->left);
if(cur->right) q.push(cur->right);
}
}
Recursive solution
void mirror(Node* node) {
// code here
if(node == NULL) return;
mirror(node->left);
mirror(node->right);
swap(node->left, node->right);
}