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:
- For this exercise, you need
to implement the RemoveAt method in the provided
MyLinkedList class.
- 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.
- 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.
- 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}
- If index is larger
than the list, the method should do nothing
- Annotate this method (put a
comment next to this method) describing the running time of that method, using
the Big "Oh" notation.
- 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.