深度优先搜索和广度优先搜索(非递归).
深度优先:
- 将openlist中的最后一项取出.
-
将其未标记的邻项标记为已访问.并放入openlist.
-
重复此步骤1.2.直到openlist为空.
例:
上图中图从P开始,openlist:
[p] [r,s,q] [r,s,t] [r,s,u] [r,s] [r] []
广度优先则是将openlist中的第一项取出.有:
[p] [r,s,q] [s,q,u] [q,u] [u,t] [t] []
Grabbing the last element means you are using a "stack". Grabbing the first means you are using a "queue". -MLL
深度优先使用的是栈.广度优先使用的是队列.
2024年1月16日 15:25
I like your post and also like your website because your website is very fast and everything in this website is good. Keep writing such informative posts. I have bookmark your website. Thanks for sharin