Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

JavaScript binary tree

//claculate the minimum height of binary tree 
const minHeightTree =(root)=>{
  if (!root) return 0;
  let left = minHeightTree(root.left);
  console.log(left)
  let right = minHeightTree(root.right);
  console.log(right)
 
  if(left< right){
 
   return left +1 ;
 
  }else { 
   return right+1 ; 
  }
 };
Source by gist.github.com #
 
PREVIOUS NEXT
Tagged: #JavaScript #binary #tree
ADD COMMENT
Topic
Name
6+8 =