Example of Breadth Search


Here is a tree the root is 1. and the goals are 9,10,11,12

Queue = Q
-----------------------------------------------------------------------
1 2
-----------------------------------------------------------------------
At the first movement
State = 1 ( is state is our goal  :::::::: Not )
Sucessor of state is added in Queue form Back   ( Q = 2 3 4 )
then state = queue[0] = 2
remove first item form queue. ( Q = 3 4 )


State = 2 ( is state is our goal  :::::::: Not )
Sucessor of state is added in Queue form    ( Q = 3 4 5 6 )
then state = queue[0] = 3
remove first item form queue. ( Q = 4 5 6 )

State = 3 ( is state is our goal  :::::::: Not )
Sucessor of state is added in Queue form Front   ( Q = 4 5 6 )
then state = queue[0] = 4
remove first item form queue. ( Q = 5 6 )

State = 4 ( is state is our goal  :::::::: Not )
Sucessor of state is added in Queue form Front   ( Q = 5 6 7 8 )
then state = queue[0] = 5
remove first item form queue. ( Q = 6 7 8 )

State = 5 ( is state is our goal  :::::::: Not )
Sucessor of state is added in Queue form Front   ( Q = 6 7 8 9 10 )
then state = queue[0] = 6
remove first item form queue. ( Q = 7 8 9 10 )

State = 6 ( is state is our goal  :::::::: Not )
Sucessor of state is added in Queue form Front   ( Q = 7 8 9 10 )
then state = queue[0] = 7
remove first item form queue. ( Q = 8 9 10 )

State = 7 ( is state is our goal  :::::::: Not )
Sucessor of state is added in Queue form Front   ( Q = 8 9 10 11 12 )
then state = queue[0] = 8
remove first item form queue. ( Q = 9 10 11 12 )

State = 8 ( is state is our goal  :::::::: Not )
Sucessor of state is added in Queue form Front   ( Q = 9 10 11 12 )
then state = queue[0] = 9
remove first item form queue. ( Q = 10 11 12 )

State = 9 ( is state is our goal  :::::::: YES ) ( But we find all goals then continue )
Sucessor of state is added in Queue form Front   ( Q = 10 11 12 )
then state = queue[0] = 10
remove first item form queue. ( Q = 11 12 )

State = 10 ( is state is our goal  :::::::: YES )
Sucessor of state is added in Queue form Front   ( Q = 11 12 )
then state = queue[0] = 11
remove first item form queue. ( Q = 12 )

State = 11 ( is state is our goal  :::::::: YES )
Sucessor of state is added in Queue form Front   ( Q = 12 )
then state = queue[0] = 12
remove first item form queue. ( Q = [] )

State = 12 ( is state is our goal  :::::::: YES )
WE FIND ALL GOALS.

Thanks.
Intelligent Programmer

Comments

Popular posts from this blog

NICOSIA