Question: Problem 3 . Extend the LinkedList class adding the following new methods: a ) [ 1 5 points ] The method called first _ index
Problem Extend the LinkedList class adding the following new
methods:
a points The method called firstindexofx that returns the
index of the first from the left node with value x If there is no such
node, return None.
The index here is how many nodes away from the head our node is
Eg applying firstindexof to the linked list
we get ; applying it to
we get
The runtime must be in On
b points The method called getmiddle that returns a list of
values of the middle nodes of a linked list. If the list has an odd
number of nodes, there will be only one middle node; otherwise,
there will be two middle nodes.
Eg applying getmiddle to the linked list
we get ; applying it to we get
The runtime must be in On
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
