Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

binary tree

// check if mirror binary tree or not (give two binary trees and you need to find if they are a mirror to each other )
const isMirror =(tree1 ,tree2)=>{
if(tree1 ===null && tree2 ===null) return true ;
if(tree1.data == tree2.data){
  if(isMirror(tree1.left ,tree2.right) && isMirror(tree1.right ,tree2.left)){
    return true 
  }else return false
} else{
  return false
} 
  }
Source by leetcode.com #
 
PREVIOUS NEXT
Tagged: #binary #tree
ADD COMMENT
Topic
Name
9+8 =