Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In Java please. Do NOT add any fields to the node or list classes. Do NOT add an

ID: 3594381 • Letter: I

Question

In Java please. Do NOT add any fields to the node or list classes.

Do NOT add any methods to the node class.

*You MAY add private methods to the class (helper functions for the recursion) static boolean showMeSuccess-false; // set to true to also see Success notifications for tests // set to false to only see Failure notifications for tests static class Node public Node (double item, Node next) this.item item; this.next next; h public double item; public Node next; Node first; // a function to compute the size of the list, using a loop // an empty list has size public int sizeIterative (O return StdRandom.uniform (100); I/TODO 1: fix this

Explanation / Answer

public int sizeIterative() {

if (first == null) return 0;

Node cur = first;

int size = 0;

while(cur!=null) {

size = size+1;

cur = cur.next;

}

return size;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote