LL: Remove At Location

advertisement
Remove A Node At An Arbitrary Index
The goal of this exercise is to make sure that you can implement the logic needed to
remove items from the middle of a linked list.
What you need to do for this exercise:
1. For this exercise, you need to implement the RemoveAt method in the
provided MyLinkedList class.
a. This class should be found in the Student_Answers.cs file, in a project
named something like 03_PCE_StudentCode. In the starter project, in
the OO_Linked_List project, you'll find a class named MyLinkedList.
2. The RemoveAt method looks like:
void RemoveAt(uint index);
You've already seen (from the lecture) how to build a function which will insert
the new integer into a linked list, at the given index, so the overall details will
not be explained here, with two exceptions.
a. Index is a ‘zero-based’ index, meaning that the first item in the list has
the index value “0”. So if the list contains {1,2, 3}, and you call
RemoveAt( 0), the the resulting list would look like: {2, 3}
b. If index is larger than the list, the method should do nothing
3. Annotate this method (put a comment next to this method) describing the
running time of that method, using the Big "Oh" notation.
4. Once you’ve completed the above task, you should run the tests in the
NUnit_Tests_LL_RemoveAt class. They should all pass at this point, and if not,
then you should fix your program so that those tests do pass. You can run the
tests using the NUnit support in the provided starter project. You should feel
free to supplement that code with your own test cases if you wish, but you are
neither required nor expected to.
a. The test cases include:
Delete a node from an empty list
Delete a node from a list with a single item in it
Delete a node from a list with two items in it
Delete a node from a list with several (~5) items in it
b. Be aware that these tests may use functionality not explicitly required
above (for example, the tests may make use of the
InsertAtFront/AddToFront method). If these other functions are not
properly working, then these tests may or may not reliably pass. You will
need to implement these methods.
Download