|
|
|
@ -39,7 +39,7 @@ const breakDown = (node)=>{
|
|
|
|
return node;
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const tree = breakDown({value:5});
|
|
|
|
const tree = breakDown({value:7});
|
|
|
|
|
|
|
|
|
|
|
|
console.dir(tree, {depth:null});
|
|
|
|
console.dir(tree, {depth:null});
|
|
|
|
|
|
|
|
|
|
|
|
@ -51,8 +51,8 @@ const getLeaves = (node)=>{
|
|
|
|
const twoRightValue = getLeaves(node.twoPath.right);
|
|
|
|
const twoRightValue = getLeaves(node.twoPath.right);
|
|
|
|
|
|
|
|
|
|
|
|
if(node.threePath !== undefined){
|
|
|
|
if(node.threePath !== undefined){
|
|
|
|
const threeLeftValue = getLeaves(node.twoPath.left);
|
|
|
|
const threeLeftValue = getLeaves(node.threePath.left);
|
|
|
|
const threeRightValue = getLeaves(node.twoPath.right);
|
|
|
|
const threeRightValue = getLeaves(node.threePath.right);
|
|
|
|
return [[twoLeftValue, twoRightValue], [threeLeftValue, threeRightValue]];
|
|
|
|
return [[twoLeftValue, twoRightValue], [threeLeftValue, threeRightValue]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -60,4 +60,4 @@ const getLeaves = (node)=>{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const leaves = getLeaves(tree);
|
|
|
|
const leaves = getLeaves(tree);
|
|
|
|
|
|
|
|
|
|
|
|
console.log(leaves);
|
|
|
|
console.dir(leaves, {depth:null});
|
|
|
|
|