mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-03 07:58:02 +00:00
Fix typos (#191)
This commit is contained in:
committed by
Donne Martin
parent
cd9e9654bc
commit
9f89a51aba
@@ -74,7 +74,7 @@
|
||||
"source": [
|
||||
"## Algorithm\n",
|
||||
"\n",
|
||||
"We'll use a recursive solution that valides left <= current < right, passing down the min and max values as we do a depth-first traversal.\n",
|
||||
"We'll use a recursive solution that validates left <= current < right, passing down the min and max values as we do a depth-first traversal.\n",
|
||||
"\n",
|
||||
"* If the node is None, return True\n",
|
||||
"* If min is set and the node's value <= min, return False\n",
|
||||
@@ -123,12 +123,12 @@
|
||||
" raise TypeError('No root node')\n",
|
||||
" return self._validate(self.root)\n",
|
||||
"\n",
|
||||
" def _validate(self, node, mininum=-sys.maxsize, maximum=sys.maxsize):\n",
|
||||
" def _validate(self, node, minimum=-sys.maxsize, maximum=sys.maxsize):\n",
|
||||
" if node is None:\n",
|
||||
" return True\n",
|
||||
" if node.data <= mininum or node.data > maximum:\n",
|
||||
" if node.data <= minimum or node.data > maximum:\n",
|
||||
" return False\n",
|
||||
" if not self._validate(node.left, mininum, node.data):\n",
|
||||
" if not self._validate(node.left, minimum, node.data):\n",
|
||||
" return False\n",
|
||||
" if not self._validate(node.right, node.data, maximum):\n",
|
||||
" return False\n",
|
||||
|
||||
@@ -93,17 +93,17 @@
|
||||
"* incoming edge count (useful for algorithms such as topological sort)\n",
|
||||
"* adjacent nodes and edge weights\n",
|
||||
"\n",
|
||||
"#### add_neighhbor\n",
|
||||
"#### add_neighbor\n",
|
||||
"\n",
|
||||
"* If the neighbor doesn't already exist as an adjacent node\n",
|
||||
" * Update the adjancet nodes and edge weights\n",
|
||||
" * Update the adjacent nodes and edge weights\n",
|
||||
" * Increment the neighbor's incoming edge count\n",
|
||||
"\n",
|
||||
"Complexity:\n",
|
||||
"* Time: O(1)\n",
|
||||
"* Space: O(1)\n",
|
||||
"\n",
|
||||
"#### remove_neighhbor\n",
|
||||
"#### remove_neighbor\n",
|
||||
"\n",
|
||||
"* If the neighbor exists as an adjacent node\n",
|
||||
" * Decrement the neighbor's incoming edge count\n",
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
"source": [
|
||||
"## Test Cases\n",
|
||||
"\n",
|
||||
"The constaints state we don't have to check for negative edges, so we test with the general case.\n",
|
||||
"The constraints state we don't have to check for negative edges, so we test with the general case.\n",
|
||||
"\n",
|
||||
"<pre>\n",
|
||||
"graph.add_edge('a', 'b', weight=5)\n",
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
"source": [
|
||||
"## Test Cases\n",
|
||||
"\n",
|
||||
"The constaints state we don't have to check for negative edges, so we test with the general case.\n",
|
||||
"The constraints state we don't have to check for negative edges, so we test with the general case.\n",
|
||||
"\n",
|
||||
"<pre>\n",
|
||||
"graph.add_edge('a', 'b', weight=5)\n",
|
||||
|
||||
Reference in New Issue
Block a user