Luke Matthews - Homework 3 Assume that a LinkedList class has been implemented as a circular singly-linked chain of nodes with no (dummy) header node. The LinkedList class has the following data members (note that there is no head data member): private Listnode tail; // references the last node private int numItems; LinkedList uses the Listnode class given in the on-line reading. Below is an implementation of a new method, moveToFront, for the LinkedList class. This method moves the object at the specified position to the front of the list. public void moveToFront( int position ) { this.add(0, this.remove(position))); } Recall that if a position is invalid, the remove method throws an IndexOutOfBoundsException. For this homework, complete a second version of moveToFront that functions that same as the code above. However, your version directly changes the chain of nodes by unlinking the node to be moved and re-linking it into the front of the list. Be sure that your code works for all cases such as when the list is empty, has just one object, or has more than one object. Also consider when the item to be moved is already at the front, is in the middle, or is at the end of the list. public void moveToFront( int position ) { if (position > numItems || position < 0) { throw new IndexOutOfBoundsException(); } //the below covers when we want to move the existing item to the front of the list //as well as if there's only one item in the list (as position has to be 0 or else // it is invalid) if (position == 0) { return; } ListNode immediatelyPriorNode = tail; int ix = 0; while(ix < position) { curNode = curNode.next(); ix++; } ListNode nodeOfInterest = immediatelyPriorNode.next(); immediatelyPriorNode.set_next(nodeOfInterest.next()); nodeOfInterest.set_next(tail.next()); tail.set_next(nodeOfInterest); }