Question: Just need some help with this exercise...I will post my solution below. DO NOT copy/paste answers from other posts about this problem. Can someone check
Just need some help with this exercise...I will post my solution below. DO NOT copy/paste answers from other posts about this problem. Can someone check my work below and confirm it does what it's supposed to do? Is my solution correct? I feel like the values I receive from the csv export are not exact right...

My solution for this pseudocode:
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException { System.out.println(collectData()); } public static long collectData() throws IOException { int L = 10000; long start = 0; long end = 0; long Tn = 0; int G[] = RData(L); int A[]; File file= new File("collectData.csv"); FileWriter filewriter = new FileWriter(file); filewriter.append("T(n)"); filewriter.append(','); filewriter.append('n'); filewriter.append(','); filewriter.append("T(n)"); filewriter.append(','); filewriter.append("T(n)log(n)"); filewriter.append(','); filewriter.append("T(n)sqrt(n)"); filewriter.append(" "); for (int n = 1000; n
public static void mergeSort(int[] Array, int p, int r) { if(p
private static void merge(int[] Array, int p, int q, int r) { // finds the sizes of the two arrays to merge int n1 = q - p + 1; int n2 = r - q; // temporary arrays created int L[] = new int[n1 + 1]; int R[] = new int[n2 + 1]; // copying the data to the temp arrays for(int i = 1; i
}
Objective: The objective of this programming assignment is to design and implement in Java the Merge-Sort algorithm presented in the lecture to sort a list of numbers. We are interested in exploring the relationship between the time complexity and the "real time". For this exploration, you will collect the execution time T(n) as a function of n and plot the functions T(n), Tn)n.log(n), and T(n) on the same graph (If you cannot see dearly the shape of the plots, feel free to separate plots.). Try to predict ahead the shapes of T(n), T(n).log(n), and T(n)yn to check whether your plots are correct. Finally, discuss your results. Program to implement collectData() Generate an array G of HUGE length L (as huge as your language allows) with random values capped at some max value (as supported by your chosen language). for n = 1,000 to L (with step 1,000) copy in Array A n first values from Array G 1/ (declare Array A only ONCE out of the loop) Take current time Start // We time the sorting of Array A of length n Merge-Sort (A, 0, n-1) Take current time End // T(n) Store the value n and the values T(n), T(n).log(n), and T(n)n in a file F where T(n) is the execution time = End Start
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
