Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

invert binary tree

// invert binary  tree using recursive function

function invertTree(node) {
  if (node && node.left) {
      let left = node.left;
      node.left = node.right;
      node.right = left;
      invertTree(node.right);
      invertTree(node.left);
  }
  return node;
}
 
PREVIOUS NEXT
Tagged: #invert #binary #tree
ADD COMMENT
Topic
Name
4+8 =