Question: Linked Lists!! Question create insert method below class _SL_Node: def __init__(self, value, next_): ------------------------------------------------------- Initializes a sorted list node. Use: node = _SL_Node(value, _next)
Linked Lists!!
Question create insert method below
class _SL_Node:
def __init__(self, value, next_): """ ------------------------------------------------------- Initializes a sorted list node. Use: node = _SL_Node(value, _next) ------------------------------------------------------- Parameters: value - value value for node (?) next_ - another sorted list node (_ListNode) Returns: Initializes a list node that contains a copy of value and a link to the next node in the list. ------------------------------------------------------- """ self._value = deepcopy(value) self._next = next_ return
def __init__(self): """ ------------------------------------------------------- Initializes an empty Sorted_List. Use: sl = Sorted_List() ------------------------------------------------------- Returns: a Sorted_List object (Sorted_List) ------------------------------------------------------- """ self._front = None self._rear = None self._count = 0
class Sorted_List:
def insert(self, value): """ ------------------------------------------------------- Inserts value at the proper place in the sorted list. Must be a stable insertion, i.e. consecutive insertions of the same value must keep their order preserved. Use: sl.insert(value) ------------------------------------------------------- Parameters: value - a data element (?) Returns: value inserted at its sorted position within the sorted list. ------------------------------------------------------- """
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
