Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Could you please finish this code and do the implementaion and add comments / lebel the where I should I the file SPY . csv

Could you please finish this code and do the implementaion and add comments/lebel the where I should I the file SPY.csv
Here is the code requirement
In the Matertials / Content / Data directory is the data file SPY.csv (or SPY.txt), which contains prices for the S&P 500 index. The file has 7 columns separated by commas: date, open, high, low, close, volume, adjusted-close.
Sort the data in SPY.csv according to the volume column, the 6th column. Use the following sort methods: selection, insertion, shell, merge, quick and radix. You will probably want to accommodate a long integer data type.
Grade points are distributed as follows:
Output, for each sort:
1.5% Displays in terminal the name of sorting algorithm
2.10% Displays in terminal the timing of sort in milliseconds
3.10% Displays in terminal the big-O versus count of elements processed
4.10% Creates 6 external files with sorted data that contains only columns 1,6 and 7
Example: SPY_radix_sorted.csv
Source code includes distinct classes:
5.30% Sort class (containing the sort methods; 5% each method)
6.5% Driver class named SortDriver
7.5% FileIO class to read and write files.
8.5% PreProcess class to condition the data before sorting.
Documentation:
9.5% Comments identify program name, purpose, author and date.
10.5% Comments identify and briefly summarize the various sorting methods.
Here is my code finish it please
import java.io.*;
import java.util.*;
public class SortDriver {
public static void main(String[] args){
// Specify the input file path
String filePath = "Materials/Content/Data/SPY.csv";
// Create an instance of PreProcess to read and condition the data
PreProcess preProcess = new PreProcess(filePath);
long[] volumeData = preProcess.getVolumeData();
// Create an instance of Sort to perform sorting
Sort sort = new Sort();
// Sort the data using various sorting algorithms
sort.selectionSort(Arrays.copyOf(volumeData, volumeData.length));
sort.insertionSort(Arrays.copyOf(volumeData, volumeData.length));
sort.shellSort(Arrays.copyOf(volumeData, volumeData.length));
sort.mergeSort(Arrays.copyOf(volumeData, volumeData.length));
sort.quickSort(Arrays.copyOf(volumeData, volumeData.length));
sort.radixSort(Arrays.copyOf(volumeData, volumeData.length));
// Display the sorted data in terminal
//(Note: External files with sorted data creation is not implemented here)
}
}
class PreProcess {
private long[] volumeData;
public PreProcess(String filePath){
// Read the data from the file and condition it
//(This part is not implemented in this example)
// Assume that volumeData is populated from the file
}
public long[] getVolumeData(){
return volumeData;
}
}
class Sort {
public void selectionSort(long[] arr){
// Selection sort implementation
}
public void insertionSort(long[] arr){
// Insertion sort implementation
}
public void shellSort(long[] arr){
// Shell sort implementation
}
public void mergeSort(long[] arr){
// Merge sort implementation
}
public void quickSort(long[] arr){
// Quick sort implementation
}
public void radixSort(long[] arr){
// Radix sort implementation
}
}
class FileIO {
// File I/O operations for reading and writing files
//(This part is not implemented in this example)
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

More Books

Students also viewed these Databases questions

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago