beyondgrader.com Logo
DemoBrowseAboutTeamLogin

SimpleLinkedList add

Geoffrey Challen // 2020.10.0

Starting with the SimpleLinkedList class below, complete the code for add. You'll want review the rest of the code to understand how this list implementation works and how to walk a linked list and manipulate the references properly.

add takes the position to add at as an Int as its first parameter and the Any reference to add as its second. add should add the element to the list, increasing the size by one and shifting elements after the add position backward. You should require that the passed position is valid for this list. But note that you should allow adding a new item to the end of the existing list.

When you are done, here is how your SimpleLinkedList class should work: