代写关于Linked List的Lab小作业,包括一个需要用Recursion的Extra point代码。
Requirement
Implement the LListCursor class as defined on iLearn. Remember, a class
invariant must be true at all times; it is an extra set of pre and post
conditions. Methods without a precondition do not have a precondition beyond
the class invariant.
The remove methods are fairly complex. I highly recommend you draw a diagram
and think about each of the possible cases such as the list being empty, the
cursor being at the item we are deleting, the cursor being at the start of the
list, the cursor being at the end of the list, etc. If you stop by my office
for help, I will ask to see your diagram for the method you are asking for
help on. I have written one of the remove methods for you. I have also written
a few test methods. You can use the checkList method as a helper for your
tests as I did in one of the sample test methods I gave you.
In addition to your LListCursor.py file, also write your own unit test file
named test_LListCursor.py. You may use mine as a starting point. My unit test
file has 20 separate tests. You should test all the possible cases for the
inserts and removes along with the other methods. See my one sample tests for
how to check that a method properly raises an assertion. Note that you do NOT
put parentheses after the method when you are using assertRaises to check if
it raises an exception.
Extra
In Python, write two different implementations of a Bag class. A Bag is
similar to a Set in that it is an unordered collection of items except that
duplicates are allowed. Write one Bag in a file named BagList.py that stores
the data as a list and write a separate implementation in a file named
BagDictionary that uses a dictionary to store the data. Each implementation
must pass the tests in the provided test Bag.py file. See the test file for
the methods the Bag class must implement. Change the import statement at the
top of the test Bag.py file depending on which implementation you are writing.
Write a C++ Bag class in files named Bag.h and Bag.cpp. Your code must pass
all the tests in the provided main.cpp file.
Write two different recursive functions named base2AsString(n)
and base2AsInt(n)
. The one returns a string such as “1011” when called with 11
and the other returns an int such as 1011 when called with 11. Your code must
pass the tests in the provided test base2.py. Write the provided linked list
assignment.