Created
November 16, 2022 14:31
-
-
Save WEEFAA/29143c7849230bbf89586a417ae2538f to your computer and use it in GitHub Desktop.
a.bfs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // -adj-node -visited | |
| function bfs(node){ | |
| let queue = [node] | |
| while(queue.length > 0){ | |
| const v = queue.shift() | |
| console.log(v.data) | |
| if(v.children){ | |
| queue.push(...v.children) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment