Question: Hello, I need assistance with this python project! If you could assist, that would be great. MPLEMENT the following functions class Node: DO NOT MODIFY
Hello, I need assistance with this python project! If you could assist, that would be great.


MPLEMENT the following functions
class Node: DO NOT MODIFY the following attributes/functions Attributes o value: T: Value held by the Node. Note that this may be any type, such as a str, int, float, dict, or a more complex object. o next: Node: Reference to the next Node in the linked list (may be None). o prev: Node: Reference to the previous Node in the linked list (may be None). _init__(self, value: T, next: Node = None, prev: Node = None) -> None o Constructs a doubly linked list node. o value: T: Value held by the Node. o next: Node: Reference to the next Node in the linked list (may be None). o prev: Node: Reference to the previous Node in the linked list (may be None). o Returns: None. _str__(self) -> str and __repr__(self) -> str o Represents the Node as a string. o Note that Python will automatically invoke this function when using printing a Node to the console, and PyCharm will automatically invoke this function when displaying a Node in the debugger. o As with all double-underscore "magic" methods in Python (see note 5), this function may be called with str(node) or repr(node). It is unnecessary (and stylistically improper) to use node. _str_ () or node. __repr__(), just as it is preferable to call len( some_list) instead of some_list. _len__(). o Returns: str. class DLL: DO NOT MODIFY the following attributes/functions Attributes o head: Node: Head (first node) of the doubly linked list (may be None). o tail: Node: Tail (last node) of the doubly linked list (may be None). o size: int: Number of nodes in the doubly linked list. o Note that the implementation in this project does not use a sentinel node. As such, an empty DLL will have head and tail attributes which are None. _init__(self) -> None o Construct an empty DLL. Initialize the head and tail to None, and set the size to zero. o Returns: None. -_str__(self) -> str and _repr__(self) -> str o Represents the DLL as a string of the form "value value ... value." o Note that Python will automatically invoke this function when using printing a DLL to the console, and PyCharm will automatically invoke this function when displaying a DLL in the debugger. o As with all double-underscore "magic" methods in Python (see note 5), this function may be called with str(dll) or repr(dll). It is unnecessary (and stylistically improper) to use dll._str_() or dll._repr__(), just as it is preferable to call len( some_list) instead of some_list. _len__(). o Returns: str. push(self, val: T, back: bool = True) -> None o Adds a Node containing val to the back (or front) of the DLL and updates size accordingly. o Suggested time complexity: O(1). o Suggested space complexity: O(1). o val: T: Value to be added to the DLL. o back: bool: If True, add val to the back of the DLL. If False, add to the front. Note that the default value is True. o Returns: None. pop(self, back: bool = True) -> None o Removes a Node from the back (or front) of the DLL and updates size accordingly. o In the case that the DLL is empty, pop does nothing. o Suggested time complexity: O(1). o Suggested space complexity: O(1). o back: bool: If True, remove from the back of the DLL. If False, remove from the front. Note that the default value is True. o Returns: None. from_list(self, source: list[T]) -> None o Creates a DLL from a standard Python list. o Suggested time complexity: O(n). o Suggested space complexity: O(n). o source: list[T]: Standard Python list from which to construct DLL. o Returns: None. to_list(self) -> list[T] o Creates a standard Python list from a DLL. o Suggested time complexity: O(n). o Suggested space complexity: O(n). o Returns: list[T] containing the values of the nodes in the DLL
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
