Question: SortedArrayList.java o Implemented the findLinear method that sequentially checks each element in the list for a particular element and returns the number of comparisons needed

 SortedArrayList.java o Implemented the findLinear method that sequentially checks each element

in the list for a particular element and returns the number of

SortedArrayList.java o Implemented the findLinear method that sequentially checks each element in the list for a particular element and returns the number of comparisons needed to find the element. o Written a short comment in findLinear that describes how the number of comparisons will scale with the number of items in the list, and whether the order of the data might affect the number of comparisons o Modified the add(E element) method so that items are automatically stored in alphabetical order o Written a main method that adds a few strings to an instance of SortedArrayList, prints the list to demonstrate that it is in alphabetical order and prints the number of comparisons needed to find one of the items. public class SortedArrayList> extends ArrayList { public SortedArrayList() { super(); } //INCOMPLETE. public boolean add(E element) { // Method to add element to the list, inserted in the correct place for the ordering of E. return super.add(element); // This will mean elements are stored in the order that they were added } // INCOMPLETE. public int findLinear(E element) { //returns the number of comparisons required to find element using Linear Search, return 0; } // INCOMPLETE. public int findBinary(E element) { //returns the number of comparisons required to find element using Binary Search. return 0; } }

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!