编程语言
首页 > 编程语言> > Python 树/搜索类算法

Python 树/搜索类算法

作者:互联网

BFS:

#1.设置队列
from queue import Queue
q = Queue()
#2.设置closed表
closed = set()/[]
#3.开始循环
while not q.empty():
    #取出
    a = q.get()
    #判断
    if a not in cloesd :
       #进入closed并进入下一步
       closed.add()/append()
       q.put()

 

标签:set,closed,Python,Queue,算法,搜索,设置,append
来源: https://www.cnblogs.com/zk505zk/p/14807974.html