BFS pseudocode
create a queue Q
mark v as visited and put v into Q
while Q is non-empty
remove the head u of Q
mark and enqueue all (unvisited) neighbours of u
BFS pseudocode
create a queue Q
mark v as visited and put v into Q
while Q is non-empty
remove the head u of Q
mark and enqueue all (unvisited) neighbours of u
bfs
function breadthFirstSearch (Start, Goal)
{
enqueue(Queue,Start)
setVisited(start)
while notEmpty(Queue)
{
Node := dequeue(Queue)
if Node = Goal
{
return Node
}
for each Child in Expand(Node)
{
if notVisited(Child)
{
setVisited(Child)
enqueue(Queue, Child)
}
}
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us