Like ripples spreading in a pond — all nodes at distance 1 are visited before distance 2.
BFS explores level by level. Start by adding the root node to the queue and marking it visited.
> queue: [A]
> visited: {A}
> order: []Like ripples spreading in a pond — all nodes at distance 1 are visited before distance 2.
BFS explores level by level. Start by adding the root node to the queue and marking it visited.
> queue: [A]
> visited: {A}
> order: []Sign in to cast your vote
Sign in to share your feedback and join the discussion.