Pages

Friday, January 24, 2014

Week 3- Exceptions & Queues

       In order to gain a better understanding of queues and stacks, I read over the Python documentation for Queues: it recommended using deque from the collections module in order to reduce the run time for enqueue and dequeue, using queue.popleft() and queue.append(). Using the module testqueue.py, the time for 10000 through 100000 items remained nearly constant: around 0.05 seconds, whilst for the lab, if I remember correctly, the time increased linearly with the increase in items. I will try to find out more about the implementation of the queue.popleft() in order to discover why this is more efficient than manually shifting the index of each element every time front() or dequeue() is used.

    Another benefit of using the Python documentation is that it seems to be following the progression of our course, so reading along from 5. Data Structures helps to reinforce ideas introduced in the lectures.

   I also looked to the Python shell in order to help me figure out how Exceptions work: the help function for Exception mentioned "Exception" as well as "BaseException," so I am trying to understand the difference between them- especially since Python documentation recommended only making subclasses inheriting from Exception, rather than BaseException.

Note: This is extremely embarrassing, but I was looking over the Abstract Data Types section for our lecture reading, and, quite unequivocally, it mentions "An abstract data type....does not specify the implementation of [its] methods..."

 

No comments:

Post a Comment