Simpilfied breadth first search challenge.

This commit is contained in:
Donne Martin
2015-08-01 17:48:12 -04:00
parent 31058abf3a
commit 332230c3a1
3 changed files with 50 additions and 65 deletions

View File

@@ -63,6 +63,18 @@
"## Code"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"%run ../bst/bst.py\n",
"%load ../bst/bst.py"
]
},
{
"cell_type": "code",
"execution_count": null,
@@ -71,27 +83,8 @@
},
"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"
"def bfs(self, visit_func):\n",
" # TODO: Implement me"
]
},
{