mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-09 10:58:02 +00:00
@@ -83,9 +83,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%run ../bst/bst.py"
|
||||
@@ -93,10 +91,8 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from __future__ import division\n",
|
||||
@@ -129,9 +125,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -143,7 +137,7 @@
|
||||
],
|
||||
"source": [
|
||||
"%%writefile test_bst_min.py\n",
|
||||
"from nose.tools import assert_equal\n",
|
||||
"import unittest\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def height(node):\n",
|
||||
@@ -153,18 +147,18 @@
|
||||
" height(node.right))\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestBstMin(object):\n",
|
||||
"class TestBstMin(unittest.TestCase):\n",
|
||||
"\n",
|
||||
" def test_bst_min(self):\n",
|
||||
" min_bst = MinBst()\n",
|
||||
" array = [0, 1, 2, 3, 4, 5, 6]\n",
|
||||
" root = min_bst.create_min_bst(array)\n",
|
||||
" assert_equal(height(root), 3)\n",
|
||||
" self.assertEqual(height(root), 3)\n",
|
||||
"\n",
|
||||
" min_bst = MinBst()\n",
|
||||
" array = [0, 1, 2, 3, 4, 5, 6, 7]\n",
|
||||
" root = min_bst.create_min_bst(array)\n",
|
||||
" assert_equal(height(root), 4)\n",
|
||||
" self.assertEqual(height(root), 4)\n",
|
||||
"\n",
|
||||
" print('Success: test_bst_min')\n",
|
||||
"\n",
|
||||
@@ -181,9 +175,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -214,9 +206,9 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.5.0"
|
||||
"version": "3.7.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
"nbformat_minor": 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user