Question: i need to create methods that: append_element(self, val) This method should increase the size of the list by one, adding the specified value in the

i need to create methods that:

append_element(self, val) This method should increase the size of the list by one, adding the specified value in the new tail position. This is the only way to add a value as the tail.

insert_element_at(self, val, index) If the provided index identifies a valid zero-based position within the list, then insert the specified value at that position, increasing the length by one. This method can be used to insert at the head of a non-empty list, but cannot append to a list. The provided index must be within the current bounds of the list. If the index is not valid, raise an IndexError exception.

remove_element_at(self, index) If the provided index identifies a valid zero-based position within the list, then remove and return the value stored in a Node at that position. If the index is not valid, raise an IndexError exception.

get_element_at(self, index) If the provided index identifies a valid zero-based position within the list, then obtain the value from the Node at that position and return it. Do not unlink the Node object. If the index is not valid, raise an IndexError exception.

class Linked_List:

class __Node:

def __init__(self, val):

# declare and initialize the private attributes

# for objects of the Node class.

# TODO replace pass with your implementation

pass

def __init__(self):

# declare and initialize the private attributes

# for objects of the sentineled Linked_List class

# TODO replace pass with your implementation

pass

def __len__(self):

# return the number of value-containing nodes in

# this list.

# TODO replace pass with your implementation

pass

def append_element(self, val):

# increase the size of the list by one, and add a

# node containing val at the new tail position. this

# is the only way to add items at the tail position.

# TODO replace pass with your implementation

pass

this is python

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!