Skip to content

Instantly share code, notes, and snippets.

@misterpoloy
Created October 6, 2021 05:50
Show Gist options
  • Save misterpoloy/35cc6fa02ff57717a85ed9f23aaffdbe to your computer and use it in GitHub Desktop.
Save misterpoloy/35cc6fa02ff57717a85ed9f23aaffdbe to your computer and use it in GitHub Desktop.
breadthFirstSearch AlgoExpert Implementation
function breadthFirstSearch(array) {
const queue = [this]
while (queue.length) {
const current = queue.shift()
array.push(current.name)
for (const child of current.children) {
queue.push(child)
}
}
return array
}
@misterpoloy
Copy link
Author

@misterpoloy
Copy link
Author

see implementation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment