Skip to content

Commit

Permalink
fixed queues text
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLeoni committed Dec 18, 2018
1 parent ebc40a9 commit 604d1d9
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 13 deletions.
2 changes: 1 addition & 1 deletion exercises/queues/circular_queue_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_04_one(self):

def test_05_two(self):
self.assertEqual(CircularQueue(2).capacity(), 2)

class EnqueueTest(unittest.TestCase):

def test_01_exceed_capacity(self):
Expand Down
33 changes: 22 additions & 11 deletions exercises/queues/queues.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,16 @@
"\n",
"**QUESTION 1.2**: If we can insert any kind of object in the queue including `None`, are we going to have troubles with definitions like `top()` above?\n",
"\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.1 Implementation\n",
"\n",
"Implement methods in file `circular_queue.py` in the order they are presented, and test them with `circular_queue_test.py`\n",
"Implement methods in file `circular_queue_exercise.py` in the order they are presented, and test them with `circular_queue_test.py`\n",
"\n",
"```bash\n",
"python3 -m unittest circular_queue_test\n",
Expand All @@ -104,7 +110,7 @@
"\n",
"You will implement an `ItalianQueue`, modelled as a LinkedList with two pointers, a `_head` and a `_tail`.\n",
"\n",
"Implement methods in file `italian_queue.py` in the order they are presented, and test them with `italian_queue_test.py`\n",
"Implement methods in file `italian_queue_exercise.py` in the order they are presented, and test them with `italian_queue_test.py`\n",
"\n",
"```bash\n",
"python3 -m unittest italian_queue_test\n",
Expand Down Expand Up @@ -241,7 +247,7 @@
"```python\n",
"\n",
"class ItalianQueue:\n",
" \"\"\" An Italian circular queue, v1. \n",
" \"\"\" An Italian queue, v1. \n",
" \n",
" - Implemented as a LinkedList\n",
" - Worst case enqueue is O(n)\n",
Expand All @@ -261,8 +267,11 @@
" \n",
" - Complexity: O(1)\n",
" \"\"\"\n",
"```\n",
" self._head = None\n",
" self._tail = None\n",
" self._size = 0\n",
"\n",
"```\n",
"\n",
"\n",
"### 2.1 Slow enqueue\n",
Expand Down Expand Up @@ -313,6 +322,8 @@
"source": [
"## 3 LinkedQueue \n",
"\n",
"Open `linked_queue_exercise.py`. \n",
"\n",
"You are given a queue implemented as a LinkedList, with usual `_head` pointer plus additional `_tail` pointer and `_size` counter\n",
"\n",
"- Data in enqueued at he right, in the tail\n",
Expand Down Expand Up @@ -527,7 +538,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Raises LookupError as there aren't enough elements to remove\n"
"Raises `LookupError` as there aren't enough elements to remove\n"
]
},
{
Expand Down Expand Up @@ -1003,7 +1014,7 @@
"source": [
"#### Implementation \n",
"\n",
"Now start editing `exerciseB2.py` implementing methods in the following points."
"Now start editing `mall_exercise.py` implementing methods in the following points."
]
},
{
Expand Down Expand Up @@ -1050,7 +1061,7 @@
" \n",
"```\n",
"\n",
"**Testing**: `python3 -m unittest exerciseB2_test.EnqueueTest` \n"
"**Testing**: `python3 -m unittest mall_test.EnqueueTest` \n"
]
},
{
Expand Down Expand Up @@ -1087,7 +1098,7 @@
" \"\"\"\n",
"```\n",
"\n",
"**Testing**: `python3 -m unittest exerciseB2_test.DequeueTest` \n",
"**Testing**: `python3 -m unittest mall_test.DequeueTest` \n",
"\n",
"\n",
"For example, suppose we have following mall:\n",
Expand Down Expand Up @@ -1437,12 +1448,12 @@
"OK\n",
"..........\n",
"----------------------------------------------------------------------\n",
"Ran 10 tests in 0.006s\n",
"Ran 10 tests in 0.009s\n",
"\n",
"OK\n",
"...............\n",
"----------------------------------------------------------------------\n",
"Ran 15 tests in 0.009s\n",
"Ran 15 tests in 0.012s\n",
"\n",
"OK\n",
".................\n",
Expand Down
2 changes: 1 addition & 1 deletion exercises/relmath/relmath.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ def __str__(self):
table.title = self.name
return table.table
"""
return tabulate(data, headers="firstrow", tablefmt="fancy_grid")
return tabulate(data, tablefmt="fancy_grid")

def __repr__(self):
return "Rel(%s,%s,%s%s)" % (repr(self.g), repr(self.dom), repr(self.cod) , self._reprname())
Expand Down
13 changes: 13 additions & 0 deletions slides.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,19 @@
"* [Graphs](exercises/graphs/graphs.ipynb) "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Lab B.9\n",
"\n",
"Tuesday December 18th, 2018\n",
"\n",
"Data structures:\n",
"\n",
"* [Graphs](exercises/graphs/graphs.ipynb) "
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down

0 comments on commit 604d1d9

Please sign in to comment.