탐색1 [Topic #자료구조 03] Binary Tree with Traverse, DFS/BFS, height 구현 with JavaScript class Node { constructor(value) { this.value = value; this.left = null; this.right = null; } } class BinaryTree { constructor() { this.root = null; } // Self, L, R #preOrder(node) { if (node) { process.stdin.write(node.value + ' > '); this.#preOrder(node.left); this.#preOrder(node.right); } } traversePreOrder() { process.stdin.write('PreOrder: '); this.#preOrder(this.root); console.log(); } // L.. 2022. 9. 12. 이전 1 다음 반응형