|
|
|
|
@ -39,7 +39,7 @@ const breakDown = (node)=>{
|
|
|
|
|
return node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const tree = breakDown({value:7});
|
|
|
|
|
const tree = breakDown({value:5});
|
|
|
|
|
|
|
|
|
|
console.dir(tree, {depth:null});
|
|
|
|
|
|
|
|
|
|
@ -47,16 +47,16 @@ const getLeaves = (node)=>{
|
|
|
|
|
if(node.twoPath === undefined){
|
|
|
|
|
return node.value;
|
|
|
|
|
}
|
|
|
|
|
const twoLeftValue = getLeaves(node.twoPath.left);
|
|
|
|
|
const twoRightValue = getLeaves(node.twoPath.right);
|
|
|
|
|
const twoPathLeftValue = getLeaves(node.twoPath.left);
|
|
|
|
|
const twoPathRightValue = getLeaves(node.twoPath.right);
|
|
|
|
|
|
|
|
|
|
if(node.threePath !== undefined){
|
|
|
|
|
const threeLeftValue = getLeaves(node.threePath.left);
|
|
|
|
|
const threeRightValue = getLeaves(node.threePath.right);
|
|
|
|
|
return [[twoLeftValue, twoRightValue], [threeLeftValue, threeRightValue]];
|
|
|
|
|
const threePathLeftValue = getLeaves(node.threePath.left);
|
|
|
|
|
const threePathRightValue = getLeaves(node.threePath.right);
|
|
|
|
|
return [[twoPathLeftValue, twoPathRightValue], [threePathLeftValue, threePathRightValue]];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return [twoLeftValue, twoRightValue];
|
|
|
|
|
return [twoPathLeftValue, twoPathRightValue];
|
|
|
|
|
}
|
|
|
|
|
const leaves = getLeaves(tree);
|
|
|
|
|
|
|
|
|
|
|