    },
    {
     "cell_type": "code",
     "execution_count": 1,
     "metadata": {
      "collapsed": false
     },
     "outputs": [],
 
</s> remove    "execution_count": 2,
 </s> add    "execution_count": 3, </s> remove    "execution_count": 4,
 </s> add    "execution_count": 5, </s> remove    "execution_count": 3,
 </s> add    "execution_count": 4, </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     "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)"
 </s> add     "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)"
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "%run ../bst/bst.py"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
    },
    {
     "cell_type": "code",
     "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "%run ../bst/bst.py"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
     "metadata": {
      "collapsed": false
     },
     "outputs": [],
keep keep keep add keep keep keep keep
 Simpilfied depth first search challenge. 
graphs_trees/tree_dfs/dfs_solution.ipynb