data-structures-and-algorithms

Linked List Insertions

Write the methods below as extensions to the LinkedList class.

Challenge

Extend the linked list with these three different methods:

.append(value) (adds a new node with the given value to the end of the list)
Input: a string value
Output: a node with the value inserted at the end of the list
Edge Case(s):

.insertBefore(value, newVal) (adds a new node with newVal immediately before the first node containing value)
Input: a value string to search for, a newVal string to insert in a new node before value
Output: a node with the newVal inserted before the searched value
Edge Case(s):

.insertAfter(value, newVal) (adds a new node with newVal immediately after the first node containing value)
Input: a value string to search for, a newVal string to insert in a new node after value
Output: a node with the newVal inserted after the searched value
Edge case(s):

Approach & Efficiency

Big O Notation

Testing

Write tests to prove the following functionality:

Whiteboard Solution

code-challenge-06 code-challenge