Question: IN PYTHON Given the code below for the class Node, write a code which builds a linked list with two nodes, such that the variable
IN PYTHON
Given the code below for the class Node, write a code which builds a linked list with two nodes, such that the variable head points to the head node of your list, and the variable tail points to the last node of your list.
class Node: """A node of a linked list""" def __init__(self, node_data): self._data = node_data self._next = None def get_data(self): """Get node data""" return self._data def set_data(self, node_data): """Set node data""" self._data = node_data data = property(get_data, set_data) def get_next(self): """Get next node""" return self._next def set_next(self, node_next): """Set next node""" self._next = node_next next = property(get_next, set_next) def __str__(self): """String""" return str(self._data)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
