      "collapsed": false
     },
     "outputs": [],
     "source": [
      "def bfs(self, visit_func):\n",
      "    # TODO: Implement me\n",
      "    pass"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
 
</s> remove     "def bfs(root, visit_func):\n",
    "    queue = deque()\n",
    "    queue.append(root)\n",
    "    while queue:\n",
    "        node = queue.popleft()\n",
    "        visit_func(node)\n",
    "        if node.left is not None:\n",
    "            queue.append(node.left)\n",
    "        if node.right is not None:\n",
    "            queue.append(node.right)"
 </s> add     "class BstBfs(Bst):\n",
    "\n",
    "    def bfs(self, visit_func):\n",
    "        if self.root is None:\n",
    "            raise Exception('root is None')\n",
    "        queue = deque()\n",
    "        queue.append(self.root)\n",
    "        while queue:\n",
    "            node = queue.popleft()\n",
    "            visit_func(node)\n",
    "            if node.left is not None:\n",
    "                queue.append(node.left)\n",
    "            if node.right is not None:\n",
    "                queue.append(node.right)" </s> remove     "        node = Node(5)\n",
    "        insert(node, 2)\n",
    "        insert(node, 8)\n",
    "        insert(node, 1)\n",
    "        insert(node, 3)\n",
    "        bfs(node, self.results.add_result)\n",
 </s> add     "        bst = BstBfs(Node(5))\n",
    "        bst.insert(2)\n",
    "        bst.insert(8)\n",
    "        bst.insert(1)\n",
    "        bst.insert(3)\n",
    "        bst.bfs(self.results.add_result)\n", </s> remove     "        node = Node(5)\n",
    "        insert(node, 2)\n",
    "        insert(node, 8)\n",
    "        insert(node, 1)\n",
    "        insert(node, 3)\n",
    "        bfs(node, self.results.add_result)\n",
 </s> add     "        bst = BstBfs(Node(5))\n",
    "        bst.insert(2)\n",
    "        bst.insert(8)\n",
    "        bst.insert(1)\n",
    "        bst.insert(3)\n",
    "        bst.bfs(self.results.add_result)\n", </s> remove         node = Node(5)
        insert(node, 2)
        insert(node, 8)
        insert(node, 1)
        insert(node, 3)
        bfs(node, self.results.add_result)
 </s> add         bst = BstBfs(Node(5))
        bst.insert(2)
        bst.insert(8)
        bst.insert(1)
        bst.insert(3)
        bst.bfs(self.results.add_result)
    "class BstBfs(Bst):\n",
    "\n",
    "    def bfs(self, visit_func):\n",
    "        # TODO: Implement me\n",
    "        pass"
      "collapsed": false
     },
     "outputs": [],
     "source": [
    "class BstBfs(Bst):\n",
    "\n",
    "    def bfs(self, visit_func):\n",
    "        # TODO: Implement me\n",
    "        pass"
    "class BstBfs(Bst):\n",
    "\n",
    "    def bfs(self, visit_func):\n",
    "        # TODO: Implement me\n",
    "        pass"
    "class BstBfs(Bst):\n",
    "\n",
    "    def bfs(self, visit_func):\n",
    "        # TODO: Implement me\n",
    "        pass"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
keep keep keep keep replace replace replace keep keep keep keep keep
 Move tree bfs to a class 
graphs_trees/tree_bfs/bfs_challenge.ipynb