Henry-Diasa / awesome_interview_question

总结前端面试题,更贴近于实战,而非背诵的八股文。
11 stars 0 forks source link

BFS #40

Open aminwangaa opened 1 year ago

aminwangaa commented 1 year ago
const node = {
    value: "A",
    children: [
        {
            value: "B",
            children: [{ value: "B1" }, { value: "B2" }]
        },
        {
            value: "C",
            children: [{ value: "C1" }, { value: "C2" }]
        }
    ]
}

const bfs = (node) => {
    console.log(node.value)
    node.children?.forEach(bfs)
}
bfs(node)
// A 
// B
// B1
// B2
// C
// C1
// C2
aminwangaa commented 1 year ago

node.left node.right node.value 前后后序遍历