mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-09 19:08:02 +00:00
@@ -124,9 +124,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%run ../bst/bst.py"
|
||||
@@ -135,9 +133,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class Solution(Bst):\n",
|
||||
@@ -175,9 +171,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -189,14 +183,14 @@
|
||||
],
|
||||
"source": [
|
||||
"%%writefile test_bst_second_largest.py\n",
|
||||
"from nose.tools import assert_equal, assert_raises\n",
|
||||
"import unittest\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestBstSecondLargest(object):\n",
|
||||
"class TestBstSecondLargest(unittest.TestCase):\n",
|
||||
"\n",
|
||||
" def test_bst_second_largest(self):\n",
|
||||
" bst = Solution(None)\n",
|
||||
" assert_raises(TypeError, bst.find_second_largest)\n",
|
||||
" self.assertRaises(TypeError, bst.find_second_largest)\n",
|
||||
" root = Node(10)\n",
|
||||
" bst = Solution(root)\n",
|
||||
" node5 = bst.insert(5)\n",
|
||||
@@ -208,13 +202,13 @@
|
||||
" node2 = bst.insert(2)\n",
|
||||
" node4 = bst.insert(4)\n",
|
||||
" node30 = bst.insert(30)\n",
|
||||
" assert_equal(bst.find_second_largest(), node20)\n",
|
||||
" self.assertEqual(bst.find_second_largest(), node20)\n",
|
||||
" root = Node(10)\n",
|
||||
" bst = Solution(root)\n",
|
||||
" node5 = bst.insert(5)\n",
|
||||
" node3 = bst.insert(3)\n",
|
||||
" node7 = bst.insert(7)\n",
|
||||
" assert_equal(bst.find_second_largest(), node7)\n",
|
||||
" self.assertEqual(bst.find_second_largest(), node7)\n",
|
||||
" print('Success: test_bst_second_largest')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
@@ -230,9 +224,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -263,9 +255,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