Я новичок в программировании на Python и все еще пытаюсь понять концепцию самости.
В этом обходе поиска в ширину я хочу узнать, что означает "я", переданное в очередь в качестве параметра.
class BinaryTree:
def __init__(self, value):
self.value = value
self.left_child = None
self.right_child = None
def bfs(self):
queue = Queue()
queue.put(self)
while not queue.empty():
current_node = queue.get()
print(current_node.value)
if current_node.left_child:
queue.put(current_node.left_child)
if current_node.right_child:
queue.put(current_node.right_child)