diff --git a/graphs_trees/tree_dfs/dfs_challenge.ipynb b/graphs_trees/tree_dfs/dfs_challenge.ipynb index 5ec8d15..699314b 100644 --- a/graphs_trees/tree_dfs/dfs_challenge.ipynb +++ b/graphs_trees/tree_dfs/dfs_challenge.ipynb @@ -18,7 +18,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Problem: Implement depth-first searches (in-order, pre-order, post-order traversals) on a binary tree.\n", + "## Problem: Implement depth-first traversals (in-order, pre-order, post-order) on a binary tree.\n", "\n", "* [Constraints](#Constraints)\n", "* [Test Cases](#Test-Cases)\n", @@ -34,6 +34,10 @@ "## Constraints\n", "\n", "* Can we assume we already have a Node class with an insert method?\n", + " * Yes\n", + "* What should we do with each node when we process it?\n", + " * Call an input method `visit_func` on the node\n", + "* Can we assume this fits in memory?\n", " * Yes" ] }, @@ -203,21 +207,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_dfs/dfs_solution.ipynb b/graphs_trees/tree_dfs/dfs_solution.ipynb index 1949c24..87aacee 100644 --- a/graphs_trees/tree_dfs/dfs_solution.ipynb +++ b/graphs_trees/tree_dfs/dfs_solution.ipynb @@ -18,7 +18,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Problem: Implement depth-first searches (in-order, pre-order, post-order traversals) on a binary tree.\n", + "## Problem: Implement depth-first traversals (in-order, pre-order, post-order) on a binary tree.\n", "\n", "* [Constraints](#Constraints)\n", "* [Test Cases](#Test-Cases)\n", @@ -34,6 +34,10 @@ "## Constraints\n", "\n", "* Can we assume we already have a Node class with an insert method?\n", + " * Yes\n", + "* What should we do with each node when we process it?\n", + " * Call an input method `visit_func` on the node\n", + "* Can we assume this fits in memory?\n", " * Yes" ] }, @@ -67,6 +71,10 @@ "\n", "## Test Cases\n", "\n", + "Note:\n", + "\n", + "* This following are all forms of depth-first traversals\n", + "\n", "### In-Order Traversal\n", "\n", "* Recursively call in-order traversal on the left child\n", @@ -77,9 +85,6 @@ "* Time: O(n)\n", "* Space: O(m), where m is the recursion depth, or O(1) if using an iterative approach\n", "\n", - "Note:\n", - "* This is a form of a depth-first traversal\n", - "\n", "### Pre-Order Traversal\n", "\n", "* Visit the current node\n", @@ -90,9 +95,6 @@ "* Time: O(n)\n", "* Space: O(m), where m is the recursion depth, or O(1) if using an iterative approach\n", "\n", - "Note:\n", - "* This is a form of a depth-first traversal\n", - "\n", "### Post-Order Traversal\n", "\n", "* Recursively call post-order traversal on the left child\n", @@ -101,10 +103,7 @@ "\n", "Complexity:\n", "* Time: O(n)\n", - "* Space: O(m), where m is the recursion depth, or O(1) if using an iterative approach\n", - "\n", - "Note:\n", - "* This is a form of a depth-first traversal" + "* Space: O(m), where m is the recursion depth, or O(1) if using an iterative approach" ] }, { @@ -279,7 +278,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.4.3" + "version": "3.5.0" } }, "nbformat": 4,