Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

NEEEEDDDDDDDDD WITHIN 1 0 MINUTES PLEASEEEEEEE!!!!!!!!!!!The file List linked.py . contains the linked implementation of the List ADT. For the List _ linked library complete

NEEEEDDDDDDDDD
WITHIN 10 MINUTES PLEASEEEEEEE!!!!!!!!!!!The file List
linked.py. contains the linked implementation of the List ADT.
For the List_linked library complete the implementation of and test the following methods with both integer and Food data. Use the same tests you used for the earlier Lists lab:
prepend, append, and insert
Hint: prepend and append are much simpler than insert, and you are allowed to call prepend and append from within insert if you wish.
_linear_search
Note tha his linear search returns more results than tharray-based linear search, which returns only an integer index. First, we can do this because the linear search is a private helper method. Because it is never supposed to be used outside the List class definition, we can tailor it to suit an array-based or a linked implementation as required. Second, it returns three values because when we find a particular node in the linked list, we may need to know what comes before this node and how many nodes we visited. We can ignore the results we don't need. (See the definition of the remove method.)
Hint: the linked linear search is used in many other methods, just as it was in the array-based implementation
count, max, and min
find, index, and
peek and remove
and
tis
List_linked.py
70 the number of values
71
72,yourcodehere
74,return
75,defprepend(self,value):
760,nwn
Adds a copy of value to the front of the List. Use: ist.prepend(value)
Parameters:
value - a data element. (?)
Returns:
None
""!
# your code herd
return
def append(self, value):
Adds a copy of value to the end of the list.
Use: Ist.append(value)
Parameters:
value - a data element (?)
Returns:
None
""
# your code here
return
def insert(self, i, value):
A copy of value is added to index i, following values are pusi If i outside of range of -len (list) to len(list)-1, the vali prepended or appended as appropriate.
Use: lst.insert(i, value)
Parameters:
i- index value (int)
value - a data element (?)
Returns:
None
# your code here
return
def ninear_search(self, key):
The file List
linked.py. contains the linked implementation of the List ADT.
For the List_linked library complete the implementation of and test the following methods with both integer and Food data. Use the same tests you used for the earlier Lists lab:
prepend, append, and insert
Hint: prepend and append are much simpler than insert, and you are allowed to call prepend and append from within insert if you wish.
_linear_search
Note the his linear search returns more results than tharray-based linear search, which returns only an integer index. First, we can do this because the linear search is a private helper method. Because it is never supposed to be used outside the List class definition, we can tailor it to suit an array-based or a linked implementation as required. Second, it returns three values because when we find a particular node in the linked list, we may need to know what comes before this node and how many nodes we visited. We can ignore the results we don't need. (See the definition of the remove method.)
Hint: the linked linear search is used in many other methods, just as it was in the array-based implementation
count, max, and min
find, index, and
peek and remove
and
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Accounting Study Guide Chapters 12-26

Authors: Ann DeCapite, Charles T. Horngren, Stephen C. Schaefer, Walter T. Harrison, Linda S. Bamber

6th Edition

0131445863, 978-0131445864