Question: java Question 1 options: Fill in the blanks in the below code implementing a LinkedList class. In this question you will be completing a constructor,
java
Question 1 options:
Fill in the blanks in the below code implementing a LinkedList class. In this question you will be completing a constructor, a for loop, a while loop, and a recursive function.
public class LinkedList { private Node first; private class Node { public int data; public Node next; public Node(int data, Node next) {


} } // returns the size of the linked list (recursive) public int size() { return

} // recursive helper function
private int size(

) {
// base case


} // returns an array that has the same data as this linked list // list[0] = first.data, etc. public int[] toArray() { int[] list = new int[size()]; int i = 0;
for (

) {

} return list; } // returns the sum of the numbers in the linked list public int sum() { int s = 0;
![data as this linked list // list[0] = first.data, etc. public int[]](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3e0333eef3_67566f3e0333080a.jpg)
while (
![toArray() { int[] list = new int[size()]; int i = 0; for](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3e03381cfd_67566f3e03368ce1.jpg)
) {


} return s; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
