Polish tree bfs challenge and solution (#77)

Update constraints and algorithm discussion.
This commit is contained in:
Donne Martin
2016-06-25 08:26:19 -04:00
committed by GitHub
parent 1321723eb9
commit c7854b69cc
2 changed files with 25 additions and 17 deletions

View File

@@ -18,7 +18,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Problem: Implement breadth-first search on a binary tree.\n",
"## Problem: Implement breadth-first traversal on a binary tree.\n",
"\n",
"* [Constraints](#Constraints)\n",
"* [Test Cases](#Test-Cases)\n",
@@ -34,7 +34,11 @@
"## Constraints\n",
"\n",
"* Can we assume we already have a Node class with an insert method?\n",
" * Yes"
" * Yes\n",
"* Can we assume this fits in memory?\n",
" * Yes\n",
"* What should we do with each node when we process it?\n",
" * Call an input method `visit_func` on the node"
]
},
{
@@ -43,7 +47,7 @@
"source": [
"## Test Cases\n",
"\n",
"### Breadth-First Search\n",
"### Breadth-First Traversal\n",
"* 5, 2, 8, 1, 3 -> 5, 2, 8, 1, 3"
]
},
@@ -156,21 +160,21 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"display_name": "Python 3",
"language": "python",
"name": "python2"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.10"
"pygments_lexer": "ipython3",
"version": "3.5.0"
}
},
"nbformat": 4,

View File

@@ -18,7 +18,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Problem: Implement breadth-first search on a binary tree.\n",
"## Problem: Implement breadth-first traversal on a binary tree.\n",
"\n",
"* [Constraints](#Constraints)\n",
"* [Test Cases](#Test-Cases)\n",
@@ -34,7 +34,11 @@
"## Constraints\n",
"\n",
"* Can we assume we already have a Node class with an insert method?\n",
" * Yes"
" * Yes\n",
"* Can we assume this fits in memory?\n",
" * Yes\n",
"* What should we do with each node when we process it?\n",
" * Call an input method `visit_func` on the node"
]
},
{
@@ -43,7 +47,7 @@
"source": [
"## Test Cases\n",
"\n",
"### Breadth-First Search\n",
"### Breadth-First Traversal\n",
"* 5, 2, 8, 1, 3 -> 5, 2, 8, 1, 3"
]
},
@@ -61,7 +65,7 @@
"\n",
"Complexity:\n",
"* Time: O(n)\n",
"* Space: O(n)"
"* Space: O(n), extra space for the queue"
]
},
{
@@ -191,21 +195,21 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"display_name": "Python 3",
"language": "python",
"name": "python2"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.10"
"pygments_lexer": "ipython3",
"version": "3.5.0"
}
},
"nbformat": 4,