Use the Node class. Create a tester module that contains the following function definitions and code for testing them. The function definitions are:
1. A function length (not len) that expects a single linked structure as argument. The function returns the number of items in the structure.
2. Define a function named insert that inserts an item into a single linked structure at a given position. The function expects three arguments: the item, the position and the linked structure (the latter may be empty). The function returns the modified linked structure. If the position is greater than or equal to the structure’s length, the function inserts the item at its end. An example call of a structure where head is length is a variable that either is an empty link or refers to the first node of a structure, is head = insert (1, data, head).
3. Define a function named remove that removes the item at a given position from singly linked structure. The function expects a position as a first argument, with the precondition 0<= position < length of structure. Its second argument is the linked structure, which, of course, cannot be empty. The function returns a tuple containing the modified linked structure and the item that was removed. An example call is (head, item) = remove (1, head).
Need help writing this program-been working on it for more than four days.
Edited 5 Years Ago by nw240x: n/a