This homework has to be prepared in teams. Find your partners on https://discordapp.com/. Download hw_9.tar.gz and extract it. Then add your homework solutions to the directory. Rename the directory according to the rules in the syllabus before submitting it as compressed archive. Don't forget to add the correct subject to the email when submitting.
All of the tasks below need to
in order to receive (full) points.
You'll have to start by implementing a decent test-suite for each of the tasks. Only when you're done with your tests, implement the task itself. The grader will mainly use your own tests to determine your score. If the test-suite is comprehensive, the grader's score will be awarded fully. Otherwise, reasonable deductions will be made.
In this homework, it is up to you to pick one of the tasks below and solve it.
DoublyLinkedList
. This data structure can be used as the widely used abstract data structures
queue or
stack.
Your task is to implement a DoublyLinkedList
such
that their program can be run without changes.first
- @property
that returns the first element.last
- @property
that returns the last element.push_back(.)
- Adds an element at the end of the doubly linked list.pop_back()
- Removes an element from the end of the doubly linked list and returns it.push_front(.)
- Adds an element at the beginning of the doubly linked list.pop_front()
- Removes an element from the beginning of the doubly linked list and returns it.elements()
- Generator method (using the command yield
)RuntimeError
if a pop method is used
on an empty list. Also do not forget to implement the __str__(self)
method!