May 2017
Intermediate to advanced
310 pages
8h 5m
English
It is still important to create a class that captures the data that our functions will be operating on:
class DoublyLinkedList(object): def __init__(self): self.head = None self.tail = None self.count = 0
For the purposes of enhancing the size method, we also set the count instance variable to 0. head and tail will point to the head and tail of the list when we begin to insert nodes into the list.
We adopt a new convention where self.head points to the beginner node of the list and self.tail points to the latest node added to the list. This is contrary to the convention we used in the singly linked list. There are no fixed rules as to the naming of the head and tail node pointers.
Doubly linked lists also need to provide ...