Question: Python 3 class LinkNode: def _init__(self, value,nxt-None) assert isinstance (nxt,LinkNode) or nxt is None self.next nxt self.head None def get_value(self): def set value (self,value): def

Python 3

Python 3 class LinkNode: def _init__(self, value,nxt-None) assert isinstance (nxt,LinkNode) or nxtis None self.next nxt self.head None def get_value(self): def set value (self,value):def get_next(self) def set_next(self,nxt): def _repr__(self) return self.value self.va lue va Lue

class LinkNode: def _init__(self, value,nxt-None) assert isinstance (nxt,LinkNode) or nxt is None self.next nxt self.head None def get_value(self): def set value (self,value): def get_next(self) def set_next(self,nxt): def _repr__(self) return self.value self.va lue va Lue return self.next self.next = nxt return repr(self.value)+ ", " + repr(self.next) Question 2.6. Insert at the given location Implement insertat which takes a linked-list, an element elem and an insertion index pos and returns the first element of the list with the element inserted at the correct location. def insert_at (elem, pos, link): >>> temp = None >>>insert_at (LinkNode (6),0, temp) 6, None >>> temp = Link ode (5) >>> insert_at (LinkNode (6),0, temp) 6, 5, None >>> temp = LinkNode (5) >insert_at (LinkNode (6),1, temp) 5, 6, None >>> temp = LinkNode ( 5 , Link Ode ( 6 , LinkNode ( 7 ) ) ) >>>insert_at (LinkNode (8),2, temp) 5, 6, 8, 7, None Question 2.7: Remove at a location Implement remove_at which takes a linked-list and a removal index pos and returns the first element of the list with the element removed from the correct location. def remove_at(pos, link): 1nn >>> temp = LinkNode ( 5 , LinkNode ( 6 , Link Ode ( 7 ) ) ) >>remove at (0,temp 6, 7, None >>> temp = LinkNode ( 5 , LinkNode ( 6 , LinkNode ( 7 ) ) ) >>> remove_at (2,temp) 5, 6, None >>> temp = LinkNode ( 5 , LinkMode ( 6 , LinkNode ( 7 ) ) ) >>> remove_at(1,temp) 5, 7, None

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!