diff --git a/random.js b/random.js index 2cf2b7f..0fe7a8e 100644 --- a/random.js +++ b/random.js @@ -39,7 +39,7 @@ const breakDown = (node)=>{ return node; } -const tree = breakDown({value:5}); +const tree = breakDown({value:7}); console.dir(tree, {depth:null}); @@ -49,13 +49,12 @@ const getLeaves = (node)=>{ } let twoPathResult = []; - const twoPathLeftValue = getLeaves(node.twoPath.left); //2 - const twoPathRightValue = getLeaves(node.twoPath.right); //[[2,3],[3,2]] + const twoPathLeftValue = getLeaves(node.twoPath.left); + const twoPathRightValue = getLeaves(node.twoPath.right); if(Number.isInteger(twoPathRightValue)){ twoPathResult[0] = twoPathLeftValue; twoPathResult[1] = twoPathRightValue; } else { - //[2] [[2,3],[3,2]] twoPathRightValue[0].unshift(twoPathLeftValue) twoPathRightValue[1].unshift(twoPathLeftValue); twoPathResult = twoPathRightValue;