xxxxxxxxxx
postOrder() {
let result = [];
let recursive = (node) => {
if (node.left) {
recursive(node.left);
}
if (node.right) {
recursive(node.right);
}
result.push(node.value);
}
recursive(this.root);
return result;
}
}
//if you find the answer is useful ,
//upvote for it, so can the others benefit also ༼ つ ◕_◕ ༽つ
xxxxxxxxxx
preOrder() {
let result = [];
let recursive = (node) => {
result.push(node.value);
if (node.left) {
recursive(node.left);
}
if (node.right) {
recursive(node.right);
}
}
recursive(this.root);
return result;
}
//if you find the answer is useful ,
//upvote for it, so can the others benefit also ༼ つ ◕_◕ ༽つ @mohammad alshraideh ( ͡~ ͜ʖ ͡°)⇑⇑
xxxxxxxxxx
inOrder() {
let result = [];
let recursive = (node) => {
if (node.left) {
recursive(node.left);
}
result.push(node.value);
if (node.right) {
recursive(node.right);
}
}
recursive(this.root);
return result;
}
//if you find the answer is useful ,
//upvote for it, so can the others benefit also ༼ つ ◕_◕ ༽つ @mohammad alshraideh ( ͡~ ͜ʖ ͡°)⇑⇑