|
|
|
|
@ -49,8 +49,8 @@ const getLeaves = (node)=>{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let twoPathResult = [];
|
|
|
|
|
const twoPathLeftValue = getLeaves(node.twoPath.left);//2
|
|
|
|
|
const twoPathRightValue = getLeaves(node.twoPath.right);//[2,2]
|
|
|
|
|
const twoPathLeftValue = getLeaves(node.twoPath.left);
|
|
|
|
|
const twoPathRightValue = getLeaves(node.twoPath.right);
|
|
|
|
|
if(Number.isInteger(twoPathRightValue)){
|
|
|
|
|
twoPathResult[0] = twoPathLeftValue;
|
|
|
|
|
twoPathResult[1] = twoPathRightValue;
|
|
|
|
|
@ -66,8 +66,8 @@ const getLeaves = (node)=>{
|
|
|
|
|
|
|
|
|
|
let threePathResult = [];
|
|
|
|
|
if(node.threePath !== undefined){
|
|
|
|
|
const threePathLeftValue = getLeaves(node.threePath.left);
|
|
|
|
|
const threePathRightValue = getLeaves(node.threePath.right);
|
|
|
|
|
const threePathLeftValue = getLeaves(node.threePath.left);//3
|
|
|
|
|
const threePathRightValue = getLeaves(node.threePath.right);//[[2,3],[3,2]]
|
|
|
|
|
if(Number.isInteger(threePathRightValue)){
|
|
|
|
|
threePathResult[0] = threePathLeftValue;
|
|
|
|
|
threePathResult[1] = threePathRightValue;
|
|
|
|
|
@ -86,9 +86,19 @@ const getLeaves = (node)=>{
|
|
|
|
|
return twoPathResult;
|
|
|
|
|
} else {
|
|
|
|
|
if(Number.isInteger(twoPathResult[0])){
|
|
|
|
|
return [twoPathResult, threePathResult]
|
|
|
|
|
if(Number.isInteger(threePathResult[0])){
|
|
|
|
|
return [twoPathResult, threePathResult]
|
|
|
|
|
} else {
|
|
|
|
|
const result = [twoPathResult];
|
|
|
|
|
result.push(threePathResult[0]);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
twoPathResult.push(threePathResult)
|
|
|
|
|
if(Number.isInteger(threePathResult)){
|
|
|
|
|
twoPathResult.push(threePathResult)
|
|
|
|
|
} else {
|
|
|
|
|
twoPathResult.push(threePathResult[0])
|
|
|
|
|
}
|
|
|
|
|
return twoPathResult;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|