mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-03 16:08:02 +00:00
@@ -137,20 +137,18 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# %load test_priority_queue.py\n",
|
||||
"from nose.tools import assert_equal\n",
|
||||
"import unittest\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestPriorityQueue(object):\n",
|
||||
"class TestPriorityQueue(unittest.TestCase):\n",
|
||||
"\n",
|
||||
" def test_priority_queue(self):\n",
|
||||
" priority_queue = PriorityQueue()\n",
|
||||
" assert_equal(priority_queue.extract_min(), None)\n",
|
||||
" self.assertEqual(priority_queue.extract_min(), None)\n",
|
||||
" priority_queue.insert(PriorityQueueNode('a', 20))\n",
|
||||
" priority_queue.insert(PriorityQueueNode('b', 5))\n",
|
||||
" priority_queue.insert(PriorityQueueNode('c', 15))\n",
|
||||
@@ -162,7 +160,7 @@
|
||||
" mins = []\n",
|
||||
" while priority_queue.array:\n",
|
||||
" mins.append(priority_queue.extract_min().key)\n",
|
||||
" assert_equal(mins, [2, 5, 15, 19, 22, 40])\n",
|
||||
" self.assertEqual(mins, [2, 5, 15, 19, 22, 40])\n",
|
||||
" print('Success: test_min_heap')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
@@ -201,9 +199,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