Fix check balance challenge spacing

This commit is contained in:
Donne Martin 2017-03-31 04:49:08 -04:00
parent 6119c3043f
commit 1e05d35fca

View File

@ -104,16 +104,16 @@
"source": [
"class BstBalance(Bst):\n",
"\n",
" def _check_height(self, node):\n",
" def _check_balance(self, node):\n",
" if node is None:\n",
" return 0\n",
" left_height = self._check_height(node.left)\n",
" left_height = self._check_balance(node.left)\n",
" if left_height == -1:\n",
" return -1\n",
" right_height = self._check_height(node.right)\n",
" right_height = self._check_balance(node.right)\n",
" if right_height == -1:\n",
" return -1\n",
" diff = abs(left_height-right_height)\n",
" diff = abs(left_height - right_height)\n",
" if diff > 1:\n",
" return -1\n",
" return 1 + max(left_height, right_height)\n",
@ -121,7 +121,7 @@
" def check_balance(self):\n",
" if self.root is None:\n",
" raise TypeError('root cannot be None')\n",
" height = self._check_height(self.root)\n",
" height = self._check_balance(self.root)\n",
" return height != -1"
]
},
@ -235,7 +235,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.0"
"version": "3.4.3"
}
},
"nbformat": 4,