(value: T, node: TreeNode<T>)
| 63 | |
| 64 | // DFS for the node matching the value |
| 65 | function findNode<T>(value: T, node: TreeNode<T>): TreeNode<T> | null { |
| 66 | if (value === node.value) return node; |
| 67 | |
| 68 | for (const child of node.children) { |
| 69 | const node = findNode(value, child); |
| 70 | if (node) return node; |
| 71 | } |
| 72 | |
| 73 | return null; |
| 74 | } |
| 75 | |
| 76 | // Return the path to the node with the given value using DFS |
| 77 | function findPath<T>(value: T, node: TreeNode<T>): TreeNode<T>[] { |
no outgoing calls
no test coverage detected
searching dependent graphs…