Question: Please write the function in python and also please include explantations for each line of code in the function and a screenshot to see the

Please write the function in python and also please include explantations for each line of code in the function and a screenshot to see the correct indentation.

Use the following to help with answering the question

The Node class definition is given as follows:

class Node: def __init__(self, data, next = None): self.__data = data self.__next = next def get_data(self): return self.__data def get_next(self): return self.__next def set_data(self, new_data): self.__data = new_data def set_next(self, new_next): self.__next = new_next def __str__(self): return str(self.__data) def add_after(self, value): new_node = Node(value, self.__next) self.__next = new_node

Extend the LinkedList class given below by adding the method add_sorted_descending(self, value) which takes a value as a parameter and inserts the value into the linked list such that all elements in the linked list are in descending order

For example, if we add the following elements to a linked list using the add_sorted_descending() method:

fruit = LinkedList() fruit.add_sorted_descending('berry') fruit.add_sorted_descending('cantaloupe') fruit.add_sorted_descending('apricots')

the resulting linked list will be as follows:

['cantaloupe', 'berry', 'apple']

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!