Double Vector A Java Class for Storing Lists of Double Values

Download Solution Order New Solution

Assignment Task

The Problem

We will be working with the list classes that we discussed in lectures, considering the issues of handling lists other than lists of integers. We will also be exploring some of the performance issues arising from the use of arrays and linked-lists for implementing these ADTs.

The Tasks

1. Write a Java class that can be used to store a list of double values using an array. Call your new class DoubleVector. As a starting point, you can download the existing IntegerVector class from RUconnected.

Write a small test program that adds a few double values to a list then prints the list out to make sure that your new class is working correctly (you don't need to hand this in).

2. Write a Java class that can be used to store a list of double values using a linked list. Call your new class DoubleList. As a starting point, you can download the existing IntegerList class from RUconnected.

Write a small test program that adds a few double values to a list then prints the list out to make sure that your new class is working correctly (again, you don't need to hand this in).

3. Write a client program to time how long it takes to add 100 000 random double values to each of your new classes. Do this twice: once adding at the end of the lists, and once at the start of the lists

4. Write a method for the DoubleVector class to add the elements of two vectors together (i.e. to do an element-by-element addition). Your method should create and return a new DoubleVector with the result of the addition, and should not modify either of the original lists. If one of the lists is shorter than the other then the values of the longer list should just be copied across to the result list, so the result list will always be as long as the longer of the two lists being added (and the result would be the same as if the shorter list was padded out with zeroes).

5. Write a method for the DoubleList class to add the elements of two lists together in the same way as in 4 above.

6. Write a client program (or extend your client program from part 3 above) to time the new addition methods for lists of 100 000 elements.

7. Lastly, we could handle the addition problem without modifying the existing list ADTs, simply by creating a new list to hold the result, then looping through the contents of the two lists using the get() method to access their contents and add them, before putting them into the new result list.
Implement addition in this way in your client program, and time how long it takes.

This IT Computer Science has been solved by our PhD Experts at My Uni Paper.

Get It Done! Today

Country
Applicable Time Zone is AEST [Sydney, NSW] (GMT+11)
+

Every Assignment. Every Solution. Instantly. Deadline Ahead? Grab Your Sample Now.