Question: /* * Complete the methods below. * All of these methods modify the list. * Use the function checkInvariants to ensure that your list is

/* * Complete the methods below. * All of these methods modify the list. * Use the function checkInvariants to ensure that your list is well-formed after you modify it. * Note that this list keeps track of the number of elements N. * It is important that N accurately reflect the length of the list. * * You may not add any fields to the node or list classes. * You may not add any methods to the node class. * * You MAY add private methods to the list class (helper functions for the recursion). */ public class MyLinked2 { static class Node { public Node (double item, Node next) { this.item = item; this.next = next; } public double item; public Node next; } int N; Node first;

// delete the kth element (where k is between 0 and N-1 inclusive) public void delete (int k) { if (k < 0 || k >= N) throw new IllegalArgumentException (); // TODO }

// reverse the list "in place"... without creating any new nodes public void reverse () { // TODO }

// remove all occurrences of item from the list public void remove (double item) { // TODO }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!