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

Hello Sir or Ma\'am, I am having trouble with the linked list(s), I cannot seem

ID: 3634439 • Letter: H

Question

Hello Sir or Ma'am,

I am having trouble with the linked list(s), I cannot seem to move pass this step. I would dearly appreciate your assistance if possible. Thank you very much!!!

-------------------------------------------------------------
One of the advantages of mergesort is that it can easily be adapted to sort a linked list of values. This is because the algorithm retrieves the values from the two lists being merged in the order that they occur in the lists. If the lists are linked lists, then that algorithm can simply move down the list node after node. With heapsort or quicksort, the algorithm needs to move values from random locations in the array, so they do not adapt as well to sorting a linked list. Write a program that sorts a linked list of integers using mergesort. The program will read the integers into a linked list and then sort the linked list using mergesort. This will require additional linked lists, but you should use linked lists, not arrays, for all your list storage.

Explanation / Answer

Merge Sort on ArrayList and LinkedList : Java package edu.neumont.csc250; import java.util.Random; import edu.neumont.csc250.LinkedList.Node; public class Tester { ArrayList arrayList1000; ArrayList arrayList10000; ArrayList arrayList100000; LinkedList linkedList1000; LinkedList linkedList10000; LinkedList linkedList100000; public Tester(){} public void createLists(){ arrayList1000 = new ArrayList(); arrayList1000 = populateRandoms(arrayList1000, 1000); arrayList10000 = new ArrayList(); arrayList10000 = populateRandoms(arrayList10000, 10000); arrayList100000 = new ArrayList(); arrayList100000 = populateRandoms(arrayList100000, 100000); linkedList1000 = new LinkedList(); linkedList1000 = populateRandoms(linkedList1000, 1000); linkedList10000 = new LinkedList(); linkedList10000 = populateRandoms(linkedList10000, 10000); linkedList100000 = new LinkedList(); linkedList100000 = populateRandoms(linkedList100000, 100000); } public ArrayList populateRandoms(ArrayList list, int size){ Random r = new Random(); for(int i = 0; i
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