Skip to content

Instantly share code, notes, and snippets.

@oreillyross
Created April 12, 2022 09:24
Show Gist options
  • Save oreillyross/1b0a7a1540af3b9ce458ed597ce4afed to your computer and use it in GitHub Desktop.
Save oreillyross/1b0a7a1540af3b9ce458ed597ce4afed to your computer and use it in GitHub Desktop.
for...of takes an iterable, so iterating left and right nodes in a BFS binary tree
for (const child of [node.left, node.right]) {
if (child) queue.push(child);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment