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

Note :this is Java . Create a linked list and populate the list with random numb

ID: 3689786 • Letter: N

Question

Note :this is Java .
Create a linked list and populate the list with random number of "n" random ints
Restrict the number of elements in the list to 1<num<20
Restrict the value of the ints to 0<int<15
Write a recursive method that takes linked list as a parameter and returns the size of the list, print the size(you are not allowed to use the .size() method from the library )
Write another recursive method by making a small change to try first which returns the sum of the values in the list. Print the sum
Print the linked list itself Note :this is Java .
Create a linked list and populate the list with random number of "n" random ints
Restrict the number of elements in the list to 1<num<20
Restrict the value of the ints to 0<int<15
Write a recursive method that takes linked list as a parameter and returns the size of the list, print the size(you are not allowed to use the .size() method from the library )
Write another recursive method by making a small change to try first which returns the sum of the values in the list. Print the sum
Print the linked list itself
Create a linked list and populate the list with random number of "n" random ints
Restrict the number of elements in the list to 1<num<20
Restrict the value of the ints to 0<int<15
Write a recursive method that takes linked list as a parameter and returns the size of the list, print the size(you are not allowed to use the .size() method from the library )
Write another recursive method by making a small change to try first which returns the sum of the values in the list. Print the sum
Print the linked list itself Create a linked list and populate the list with random number of "n" random ints
Restrict the number of elements in the list to 1<num<20
Restrict the value of the ints to 0<int<15
Write a recursive method that takes linked list as a parameter and returns the size of the list, print the size(you are not allowed to use the .size() method from the library )
Write another recursive method by making a small change to try first which returns the sum of the values in the list. Print the sum
Print the linked list itself

Explanation / Answer

/*

* To change this template, choose Tools | Templates

* and open the template in the editor.

*/

/**

*

* @author RAM

*/

import java.util.*;

class LinkedListRecursive {

     public static void main(String args[]) {

         /* Linked List Declaration */

         LinkedList<String> linkedlist = new LinkedList<String>();

         /*add(String Element) is used for adding

          * the elements to the linked list*/

         int i,num;

         for(i=0;i<=20;i++){

             for(num=0;num<=15;num++){

                 linkedlist.add("value1");

            }

         }

         /*Display Linked List Content*/

         System.out.println("Linked List Content: " +linkedlist);

         /*Add First and Last Element*/

         linkedlist.addFirst("First Item");

         linkedlist.addLast("Last Item");

         System.out.println("LinkedList Content after addition: " +linkedlist);

         /*This is how to get and set Values*/

         Object firstvar = linkedlist.get(0);

         System.out.println("First element: " +firstvar);

         linkedlist.set(0, "Changed first item");

         Object firstvar2 = linkedlist.get(0);

         System.out.println("First element after update by set method: " +firstvar2);

         linkedlist.removeFirst();

         linkedlist.removeLast();

         System.out.println("LinkedList after deletion of first and last element: " +linkedlist);

         linkedlist.add(0, "Newly added item");

         linkedlist.remove(2);

         System.out.println("Final Content: " +linkedlist);

     }

}

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