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()

 

上一篇:Event loop is closed


下一篇:sql: database is closed