广度搜索的文字说明

来源:百度知道 编辑:UC知道 时间:2024/06/17 23:15:20
最好是pascal
详细一点,
我大概知道是什么原理,但写不出来,看程序有看不懂

[广度搜索]<Type> Node(节点类型)=Record Situtation:TSituation(当前节点状态); Level:Integer(当前节点深度); Last :Integer(父节点); End<Var> List(节点表):Array[1..Max(最多节点数)] of Node(节点类型); open(总节点数):Integer; close(待扩展节点编号):Integer; New-S:TSituation;(新节点)<Init> List<-0; open<-1; close<-0; List[1].Situation<- 初始状态; List[1].Level:=1; List[1].Last:=0;<Main Program> While (close<open(还有未扩展节点)) and (open<Max(空间未用完)) and (未找到目标节点) do Begin close:=close+1; For I:=1 to TotalExpendMethod do(扩展一层子节点) Begin New-S:=ExpendNode(List[close].Situation,I); If Not (New-S in List) then (扩展出的节点从未出现过) Begin open:=open+1; List[open].Situation:=New-S; List[open].Level:=List[close].Level+1; List[open].Last:=close; End-If End-For; End-While;