I need help with my Python Code. I am missing several requirements for my code to work properly as stated by the attachments. Attached are the prompt, specifics, and missed test results from my current code.
Write a LinkedList class that has recursive implementations of the add and
remove methods described in the Exploration. It should also have recursive
implementations of the contains , insert, and reverse methods
described in the exercises. The reverse method should not change the data
value each node holds – it must rearrange the order of the nodes in the linked
list (by changing the next value each node holds).
It should have a recursive method named to_plain_list that takes no
parameters and returns a regular Python list that has the same values (from
the data attribute of the Node objects), in the same order, as the current
state of the linked list.
It should have a method named get_head that takes no parameters and
returns the Node object (not the value inside it) that is at the _head of the
linked list.
The head data member of the Linked List class, as well as the data and
next members for the Node class must be private and have getters and
setters defined.
All the methods should have the arguments in the same order as you saw in
the Lesson. You may use default arguments and/or helper functions.
Your recursive functions must not:
.
.
use any loops
use any variables declared outside of the function
use any mutable default arguments
.
Here’s an example of how a recursive version of the display() method from
the lesson could be written:
def rec_display(self, a_node):
“”‘”recursive display method”.
if a_node is None:
return
print(a_node.get_data(), end=” “)
self.rec_display(a_node.get_next())
def display (self):
“”recursive display helper method
self.rec_display(self.get_head())
It should have a method named get_head that takes no parameters and
returns the Node object (not the value inside it) that is at the _head of the
linked list.
The head data member of the LinkedList class, as well as the data and
next members for the Node class must be private and have getters and
setters defined.
FAILED TESTS
test that a LinkedList can be created and a single
Node can be added to it which can be then
checked with calling get_data() on that Node
(0.0/1.0)
test that calling reverse() on the LinkedList
reverses the LinkedList by only changing the
order and not the values (0.0/1.0)
test that a LinkedList object has a get_head()
method which returns the head Node object,
when a Node has been added (0.0/1.0)
test that a LinkedList’s get_head() method returns
a reference to the correct node when many nodes
have been added (0.0/1.0)
test that we can add 3 nodes to a LinkedList and
then remove 1 of those can be removed (0.0/1.0)
test that we can add and then remove 3 nodes
from a LinkedList (0.0/1.0)
test that a LinkedList returns None when
get_head() is called on an empty Linked List
(0.0/1.0)
test that a Node object has a get_next() method
that returns a reference to the next Node when
there are more than one Node in the LinkedList
(0.0/1.0)
test that a Node object has a get_next() method
that returns None when that Node is the only
Node in the LinkedList (0.0/1.0)
test that we can insert correctly between two
nodes in an already populated Linked List and the
values of the Nodes will be correct 100/10