From c7854b69cce1a84225ffaa5ccd19ef468eb910ad Mon Sep 17 00:00:00 2001 From: Donne Martin Date: Sat, 25 Jun 2016 08:26:19 -0400 Subject: [PATCH] Polish tree bfs challenge and solution (#77) Update constraints and algorithm discussion. --- graphs_trees/tree_bfs/bfs_challenge.ipynb | 20 ++++++++++++-------- graphs_trees/tree_bfs/bfs_solution.ipynb | 22 +++++++++++++--------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/graphs_trees/tree_bfs/bfs_challenge.ipynb b/graphs_trees/tree_bfs/bfs_challenge.ipynb index 11f78a6..3fbc1f1 100644 --- a/graphs_trees/tree_bfs/bfs_challenge.ipynb +++ b/graphs_trees/tree_bfs/bfs_challenge.ipynb @@ -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, diff --git a/graphs_trees/tree_bfs/bfs_solution.ipynb b/graphs_trees/tree_bfs/bfs_solution.ipynb index 6fd38db..a6bd1e8 100644 --- a/graphs_trees/tree_bfs/bfs_solution.ipynb +++ b/graphs_trees/tree_bfs/bfs_solution.ipynb @@ -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,