      "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 = type(self)(data)\n",
      "            else:\n",
      "                self.left.insert(data)\n",
      "        else:\n",
      "            if self.right is None:\n",
      "                self.right = type(self)(data)\n",
      "            else:\n",
      "                self.right.insert(data)\n",
      "\n",
      "    def in_order_traversal(self, visit_func):\n",
      "        if self.left is not None:\n",
      "            self.left.in_order_traversal(visit_func)\n",
      "        visit_func(self.data)\n",
      "        if self.right is not None:\n",
      "            self.right.in_order_traversal(visit_func)\n",
      "\n",
      "    def pre_order_traversal(self, visit_func):\n",
      "        visit_func(self.data)\n",
      "        if self.left is not None:\n",
      "            self.left.pre_order_traversal(visit_func)\n",
      "        if self.right is not None:\n",
      "            self.right.pre_order_traversal(visit_func)\n",
      "\n",
      "    def post_order_traversal(self, visit_func):\n",
      "        if self.left is not None:\n",
      "            self.left.post_order_traversal(visit_func)\n",
      "        if self.right is not None:\n",
      "            self.right.post_order_traversal(visit_func)\n",
      "        visit_func(self.data)"
     ]
    },
    {
     "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 = type(self)(data)\n",
    "            else:\n",
    "                self.left.insert(data)\n",
    "        else:\n",
    "            if self.right is None:\n",
    "                self.right = type(self)(data)\n",
    "            else:\n",
    "                self.right.insert(data)\n",
    "\n",
    "    def in_order_traversal(self, visit_func):\n",
    "        # TODO: Implement me\n",
    "\n",
    "    def pre_order_traversal(self, visit_func):\n",
    "        # TODO: Implement me\n",
    "\n",
    "    def post_order_traversal(self, visit_func):\n",
    "        # TODO: Implement me"
 </s> add     "def in_order_traversal(node, visit_func):\n",
    "    # TODO: Implement me\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    # TODO: Implement me\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    # TODO: Implement me" </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 = 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 = Node(1)\n",
    "        root.insert(2)\n",
    "        root.insert(3)\n",
    "        root.insert(4)\n",
    "        root.insert(5)\n",
 </s> add     "        node = Node(1)\n",
    "        insert(node, 2)\n",
    "        insert(node, 3)\n",
    "        insert(node, 4)\n",
    "        insert(node, 5)\n", </s> remove     "        root = Node(1)\n",
    "        root.insert(2)\n",
    "        root.insert(3)\n",
    "        root.insert(4)\n",
    "        root.insert(5)\n",
 </s> add     "        node = Node(1)\n",
    "        insert(node, 2)\n",
    "        insert(node, 3)\n",
    "        insert(node, 4)\n",
    "        insert(node, 5)\n",
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
      "collapsed": false
     },
     "outputs": [],
     "source": [
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
    "def in_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        in_order_traversal(node.left, visit_func)\n",
    "        visit_func(node.data)\n",
    "        in_order_traversal(node.right, visit_func)\n",
    "\n",
    "def pre_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        visit_func(node.data)\n",
    "        pre_order_traversal(node.left, visit_func)\n",
    "        pre_order_traversal(node.right, visit_func)\n",
    "\n",
    "def post_order_traversal(node, visit_func):\n",
    "    if node is not None:\n",
    "        post_order_traversal(node.left, visit_func)\n",
    "        post_order_traversal(node.right, visit_func)\n",
    "        visit_func(node.data)"
     ]
    },
    {
     "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 replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 Simpilfied depth first search challenge. 
graphs_trees/tree_dfs/dfs_solution.ipynb