Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

JavaScript binary tree

// minimum node in binary tree
const BreadthFirstsearchMin =(root)=>{
let min = Infinity ;
let queue = [root];
while(queue.length){
let current = queue.shift();
if(current.data < min) {
  min=current.data;
}
if(current.left!== null) queue.push(current.left);
if(current.right !==null) queue.push(current.right);
}
return min ;
}
Source by gist.github.com #
 
PREVIOUS NEXT
Tagged: #JavaScript #binary #tree
ADD COMMENT
Topic
Name
4+1 =