Skip to Content
算法技术手册(原书第2 版)
book

算法技术手册(原书第2 版)

by George T.Heineman, Gary Pollice, Stanley Selkow
August 2017
Intermediate to advanced
360 pages
8h 35m
Chinese
China Machine Press
Content preview from 算法技术手册(原书第2 版)
184
7
if closed doesn't contain nextState then
nextState.depth = n.depth + 1
if nextState = goal then return "Solution"
if nextState.depth < maxDepth then
insert (open, nextState)
return "No Solution"
end
深度优先搜索
使用栈来存储那要被访问的开集状态
将下一个要访问的状态从栈中弹出。
深度优先搜索
不会越过
maxDepth
将下一个状态加入开集
open
中,使用
push
操作,因为
open
是一个栈。
深度优先搜索
维护一个栈,即开集
open
保存未访问过的棋状态)和 一个闭集
closed
存已经访问过的状态。在每次迭代时,
深度优先搜索
从栈中弹出一个未访问的棋状态,
然后从这个棋状态开始扩展,根据走法计算其后继棋局状态。如果达到了目标棋局状
态,搜索终止。算法在扩展时,对于任何后继棋状态,如果检查发现它已经在闭集中,
那么算法就会抛弃这个状态,而未访问棋状态会被压入栈中,以供后续搜索。
如图
7-15
所示,在一个八数码问题中,限定最大深度为
9
,从初始棋状态开始计
算出一棵搜索树。可以看到,虽然有些地方已经扩展到深度
9
,但是找到解(标记为
GOAL
)只需经过
8
步。在这棵树中,总共访问了 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

机器学习实战:基于Scikit-Learn、Keras 和TensorFlow (原书第2 版)

机器学习实战:基于Scikit-Learn、Keras 和TensorFlow (原书第2 版)

Aurélien Géron
Go语言编程

Go语言编程

威廉·肯尼迪

Publisher Resources

ISBN: 9787111562221