      "collapsed": false
     },
     "outputs": [],
     "source": [
      "class Node(object):\n",
      "\n",
      "    def __init__(self, data):\n",
      "        self.data = data\n",
      "        self.left = None\n",
      "        self.right = None\n",
      "\n",
      "    def insert(self, data):\n",
      "        if data <= self.data:\n",
      "            if self.left is None:\n",
      "                self.left = Node(data)\n",
      "            else:\n",
      "                self.left.insert(data)\n",
      "        else:\n",
      "            if self.right is None:\n",
      "                self.right = Node(data)\n",
      "            else:\n",
      "                self.right.insert(data)\n",
      "\n",
      "    def bfs(self, visit_func):\n",
      "        # TODO: Implement me"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
 
</s> remove     "class Node(object):\n",
    "\n",
    "    def __init__(self, data):\n",
    "        self.data = data\n",
    "        self.left = None\n",
    "        self.right = None\n",
    "\n",
    "    def insert(self, data):\n",
    "        if data <= self.data:\n",
    "            if self.left is None:\n",
    "                self.left = Node(data)\n",
    "            else:\n",
    "                self.left.insert(data)\n",
    "        else:\n",
    "            if self.right is None:\n",
    "                self.right = Node(data)\n",
    "            else:\n",
    "                self.right.insert(data)\n",
    "\n",
    "    def bfs(self, visit_func):\n",
    "        queue = deque()\n",
    "        queue.append(self)\n",
    "        while len(queue) > 0:\n",
    "            node = queue.popleft()\n",
    "            visit_func(node.data)\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     "def bfs(root, visit_func):\n",
    "    queue = deque()\n",
    "    queue.append(root)\n",
    "    while len(queue) > 0:\n",
    "        node = queue.popleft()\n",
    "        visit_func(node.data)\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     "        root = Node(5)\n",
    "        root.insert(2)\n",
    "        root.insert(8)\n",
    "        root.insert(1)\n",
    "        root.insert(3)\n",
 </s> add     "        node = Node(5)\n",
    "        insert(node, 2)\n",
    "        insert(node, 8)\n",
    "        insert(node, 1)\n",
    "        insert(node, 3)\n", </s> remove     "            root.bfs(sys.stdout.write)\n",
 </s> add     "            bfs(node, sys.stdout.write)\n", </s> remove         root = Node(5)
        root.insert(2)
        root.insert(8)
        root.insert(1)
        root.insert(3)
 </s> add         node = Node(5)
        insert(node, 2)
        insert(node, 8)
        insert(node, 1)
        insert(node, 3)
    "def bfs(self, visit_func):\n",
    "    # TODO: Implement me"
      "collapsed": false
     },
     "outputs": [],
     "source": [
    "def bfs(self, visit_func):\n",
    "    # TODO: Implement me"
    "def bfs(self, visit_func):\n",
    "    # TODO: Implement me"
    "def bfs(self, visit_func):\n",
    "    # TODO: Implement me"
    "def bfs(self, visit_func):\n",
    "    # TODO: Implement me"
    "def bfs(self, visit_func):\n",
    "    # TODO: Implement me"
    "def bfs(self, visit_func):\n",
    "    # TODO: Implement me"
    "def bfs(self, visit_func):\n",
    "    # TODO: Implement me"
    "def bfs(self, visit_func):\n",
    "    # TODO: Implement me"
    "def bfs(self, visit_func):\n",
    "    # TODO: Implement me"
    "def bfs(self, visit_func):\n",
    "    # TODO: Implement me"
    "def bfs(self, visit_func):\n",
    "    # TODO: Implement me"
    "def bfs(self, visit_func):\n",
    "    # TODO: Implement me"
    "def bfs(self, visit_func):\n",
    "    # TODO: Implement me"
    "def bfs(self, visit_func):\n",
    "    # TODO: Implement me"
    "def bfs(self, visit_func):\n",
    "    # TODO: Implement me"
    "def bfs(self, visit_func):\n",
    "    # TODO: Implement me"
    "def bfs(self, visit_func):\n",
    "    # TODO: Implement me"
    "def bfs(self, visit_func):\n",
    "    # TODO: Implement me"
    "def bfs(self, visit_func):\n",
    "    # TODO: Implement me"
    "def bfs(self, visit_func):\n",
    "    # TODO: Implement me"
    "def bfs(self, visit_func):\n",
    "    # TODO: Implement me"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 Simpilfied breadth first search challenge. 
graphs_trees/tree_bfs/bfs_challenge.ipynb