BEST FIRST SEARCH算法

**BEST FIRST SEARCH算法**

Korf illustrated the workings of this algorithm with a binary tree where f(N) = the depth of node N.  What follows is a brief, structured description of how the algorithm works in this case.  It is best to try to work the algorithm on your own on paper and use this as a reference to check your work. Nodes in the binary tree are named A, B, C, … from left-to-right, top-to-bottom.  Assume the tree is infinite and has no goal.  Note that the stored value F(N) is different from f(N).  When sorted children are listed (e.g. “B(1) C(1)”), the number inside the parentheses is the stored value.  Recursive calls are indented; the first line is the initial call on the root.
代码块:

RBFS (node: N, value: F(N), bound: B)

IF f(N)>B, RETURN f(N)

IF N is a goal, EXIT algorithm

IF N has no children, RETURN infinity

FOR each child Ni of N,

  IF f(N)<F(N), F[i] := MAX(F(N),f(Ni))

  ELSE F[i] := f(Ni)

sort Ni and F[i] in increasing order of F[i]

IF only one child, F[2] := infinity

WHILE (F[1] <= B and F[1] < infinity)

  F[1] := RBFS(N1, F[1], MIN(B, F[2]))

  insert Ni and F[1] in sorted order

RETURN F[1]

## 分割线
 RBFS(A, 0, 4)

f(A)=F(A), so F(B)=f(B)=1, F(C)=f(C)=1

Sorted children: B(1) C(1)

F(B)< 4, so

     RBFS(B, 1, 1)

     f(B)=F(B), so F(D)=f(D)=2, F(E)=f(E)=2

     Sorted children: D(2) E(2)

     F(D)>1, so return 2

F(B)=2

Sorted children: C(1) B(2)

F(C)< 4, so

     RBFS(C, 1, 2)

     f(C)=F(C), so F(F)=f(F)=2, F(G)=f(G)=2

     Sorted children: F(2) G(2)

     F(F)<=2, so

           RBFS(F, 2, 2)

           … search F’s children to 2 returning min cost beyond …

           return 3

     F(F)=3

     Sorted children: G(2) F(3)

     F(G)<=2, so

           RBFS(G, 2, 2)

           … search G’s children to 2 returning min cost beyond …

           return 3

     F(G)=3

     Sorted children: F(3) G(3)

     F(F)>2, so return 3

F(C)=3

Sorted children: B(2) C(3)

F(B)< 4, so

     RBFS(B, 2, 3)

     f(B)<F(B), so F(D)=MAX(F(B),f(D))=2,

   F(E)=MAX(F(B),f(E))=2

     Sorted children: D(2) E(2)

     F(D)<=3, so

RBFS(D, 2, 2)

… search D’s children to 2 returning min cost beyond …

return 3

     F(D)=3

     Sorted children: E(2) D(3)

     F(E)<=3, so

RBFS(E, 2, 3)

… search E’s children to 3 returning min cost beyond …

return 4

     F(E)=4

Sorted children: D(3) E(4)

F(D)<=3, so

RBFS(D, 3, 3)

… search D’s children to 3 returning min cost beyond …

return 4

     F(D)=4

Sorted children: E(4) D(4)

F(E)>3, so return 4

F(B)=4

Sorted children: C(3) B(4)

F(C)< 4, so

     RBFS(C, 3, 4)

     … search C’s children to 4 returning min cost beyond …

     return 5

F(C)=5

Sorted children: B(4) C(5)

F(B)< 4, so

     RBFS(B, 4, 5)

     … search B’s children to 5 returning min cost beyond …

     return 6

F(B)=6

Sorted children: C(5) B(6)


**and so  on。。。。**

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zy_destiny

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值