Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

JavaScript binary tree

// calculate the maximum height of binary tree  
const maxHeightTree = (root) => {
  if (!root) return 0;
 let left = maxHeightTree(root.left);
  console.log(left)
 let right = maxHeightTree(root.right);
 console.log(right)

 if(left> right){

  return left +1 ;

 }else { 
  return right+1 ; 
 }
};
Source by rocoderes.com #
 
PREVIOUS NEXT
Tagged: #JavaScript #binary #tree
ADD COMMENT
Topic
Name
3+9 =