Question: please answer In this assignment you will implement an abstract list data type NumList that can be used to represent an ordered sequence of double

please answer
please answer In this assignment you will implement an abstract list data

In this assignment you will implement an abstract list data type NumList that can be used to represent an ordered sequence of double precision floating-point numbers. The NumList interface should be implemented using a NumArrayList class. You are not allowed to use the Java built-in ArrayList class. The point of this exercise is to implement a simple ADT from scratch. The reason for doing it this way is to provide a com- mon interface that can be implemented in different ways. In a later assignment, you will write a different implementation using a linked list which will have different run time properties. Your ADTs should use the exact names specified below, including the case. Start with a complete set of empty method definitions to ensure your code compiles against the grading test set. 1. NumList and NumArrayList With no parameters, the constructor should initialize an empty list. I A constructor with an integer argument should initialize an empty list with that capacity. You should efficiently handle the case when there is no space to insert into the array by expanding its capacity size() returns the size of the list, i.e. the number of elements in the sequence. int capacity returns the capacity of the array, i.e. the number of elements it can currently hold (which is not the same as size). void add(double value) adds a new element to the end of the current list. void insert(int i, double value) inserts a new element before the i-th element of the list (using 0 for the index of the first element). Thus, the inserted element becomes the i-th element. For the case when the list has i or fewer elements, insert the new element at the end of the list. void remove(int i) removes the i-th element of the list (using 0 for the index of the first element). For the case when the list has fewer than i elements, do nothing since the element to be removed does not exist. boolean contains(double value) returns true if the list contains value, False if it doesn't double lookup (int i) returns the i-th element of the list (using o for the index of the first element). Raise an exception if the list has fewer than 1+1 elementa, boolean equals(Numlist otherList) returns true if the otherList equals the other list void removeDuplicates remove duplicates of any elements in the list, preserving the list order and the position of the first of the duplicates. For example, removing the duplicates of the list (1. 2. 3. 1, 2, 4] should result in 1, 2, 3, 4]. String toString() convert the contents of the list to a string. For an empty list, it should return a null String. The elements should be formatted as they were provided, and should be separated by a ainale wandeninin nathar chorar

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!