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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started