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) {

java Question 1 options: Fill in the blanks in the below code

implementing a LinkedList class. In this question you will be completing a

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

return

constructor, a for loop, a while loop, and a recursive function. public

 } // recursive helper function 

private int size(

class LinkedList { private Node first; private class Node { public int

) {

 // base case 

data; public Node next; public Node(int data, Node next) { } }

 

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

 } // 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 } // recursive helper function private int size( ) {

) {

// base case } // returns an array that has the same

 } 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[]

while (

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

 } return s; } 

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!