Question: In this lab, you will be implementing your own Array List with the property that it always keeps items in a sorted manner. We will


In this lab, you will be implementing your own Array List with the property that it always keeps items in a sorted manner. We will call it SortedArrayList. You cannot make use of ArrayList for this lab (defeats the entire purpose of this exercise). You may assume you are working with integers only. You need to implement the following: Your class should have 2 constructors: - The default constructor should initialize an array to store 10 elements (we call this capacity). What this means is that we can initially store 10 elements and that there are no elements currently in the list. - The second constructor should take in a number and initialize an array of this length. Furthermore, each constructor should also initialize the size of the list to be 0 (this is the total number of elements in the list). InsertSorted: Should take in the value to be inserted. It needs to insert this item, so that the list remains sorted. You may need to resize the original array in order to complete this operation. Please double the capacity of the array if needed. For instance, lets assume that the capacity is 10 and there are already 10 elements in the list, and you are trying to insert another. The method should double the size of the array and copy all elements before inserting. Delete: Should take in an index that is to be deleted. If the index is negative, or equal or greater than the size (not the capacity), it should generate an IndexOutOfBoundsException Otherwise, it should delete that item at provided index. You must ensure there are no holes in your list. Search: Should take in a value to search for and return the index of this item. If the item is not found, it should return -1. Since the list is sorted, you can use binary search to do this. Get: Should take in an index. If the index is negative, or equal or greater than the size, it should generate an IndexOutofBoundsException Otherwise, it should return the item at the provided index. Test Cases Using Junit, please provide test cases that test the accuracy of your methods. You should test insertSorted, delete, get, and search. Remember, your tests should have 100% code coverage. Grading Rubric - Attendance: 1pt - Test cases: 2pt - InsertSorted: 2 pt - Delete: 2 pt - Get: 2 pt - Search: 2 pt - Constructors: 2 pts We will be looking to see if your methods follow the expected time complexities Submit to Canvas (not zipped) - SortedArrayList.java - SortedArrayListTest.java
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
