CSC220程序 写作、data留学生程序 写作

” CSC220程序 写作、data留学生程序 写作CSC220 Lab05Searching and RecursionThe goal of this weeks lab is:1. Practice searching2. Continue learning the significance of special cases!3. Learning how to Write test to check your implementationThings you must do:1. There are many details in this lab. Make sure you read the whole thing carefullybefore writing any code and closely follow this instruction.2. Always remember Java is case sensitive.3. Your file names, class names, and package name must match exactly asthey are specified here.Things you Must not do:1. You must not change the file names, class names, package names.2. You must not change the signature of any of these methods (name, parameters,). Just fill in the missing code inside them. However, you are more than welcometo create any helper methods you need as necessary.Part 0 Create a new Java project and call it Lab05. Create a package inside your project and call it lab05. Download the Lab05-Assignment05 ZIP folder from Google Drive (link fromblackboard assignment). Copy and paste the following files into your newlab05 package: SortedBinarySet.java. This file will Contain the representation of the classyou are about to implement.CSC220作业 写作、data留学生作业 写作 Tester.java. This file will contain the main function and tests forSortedBinarySet.Part 1 – SortedBinarySet Class DescriptionFor this lab (and assignment), you are asked to construct a class calledSortedBinarySet that handles a list(s) of doubles. We have provided the skeleton ofthis class for you. This class requires: All of the usual operations for a list, such as the ability to add items, removeitems, search for items, grow itself before running out of space. You must make your search routine(s) as efficient as possible. You are notallowed to use sort algorithms. Instead, you need to consider the fact thatany list will begin as an empty list (which is already in sorted order), and youcan simply insert items in the correct order to ensure that the list remains sortedat all times. Furthermore, the list must not contain any duplicates. (Because its a set) The data in SortedBinarySet must be backed by a basic array (do not use aJava List, ArrayList, or Any other Java class). It is not acceptable for the array to run out of space for new items, nor is itacceptable to create a Gigantic array. We will start with a modestly-sized array,say size 11, and increase the capacity as needed (see the grow() functiondescription). Unlike previous assignments you are not given any tests as a starting point.You must create your own tests and submit them with your program. (Notethat the previous assignment will be very useful in helping you accomplishthis).Part 2 SortedBinarySet Class ImplementationWe start by implementing the easier methods. Remember that the list must besorted at all times. Please pay close attention to the following notes:● public SortedBinarySet() // default constructor○ This constructor must initialize an array of size 11 (hint: use the finalvariable INITIAL_STORAGE_CAPACITY)○ and set the rest of the field members accordingly. Pay attention to themember variables of the class! Each should be set to some(appropriate) initial value.● public boolean empty()○ returns true only if theData in the SortedBinarySet contains no elements● public int size()○ returns the number of elements in this SortedBinarySet.● public void grow()○ this function doubles the size of theData and modifies member variablesaccordingly.○ consult this weeks slides● public String toString()○ this method will print the elements of the list, its capacity, and its current size.○ This method is purely to help you test your implementation.○ We will NOT test your toString() method when grading.● private int SequentialFind(double target)○ this method will Return the index where the element target occurs. This methodmust make use of the Sequential search we learned in class. If target is not presentin the list, then it Should return the index where it should be added (-index – 1).Does this formula make sense?○ There are three Cases to consider. What should be returned in each?■ target is equal to TheData[index]■ target becomes less than theData[index]■ the loop terminates without success● public boolean insert(double newVal)○ If the list does not contain newVal, add it to the correct position of the list andreturn true. If the list already includes the value, return false.○ The method should first make sure there is enough room in the list to handle theoperation. If not, what should you do?○ It should then make a call to findIndex(), which then calls the privatesequentialFind you just implemented, to see if newVal already occurs in thelist (how do we know?). If it isnt in the list, the index returned by findIndex specifiesthe position where newVal is to be inserted (but it is negative! what should youdo? :-)○ Be careful about which member variables should be updated before returning true.● public void clear()○ Removes all the Elements from the list. A call to empty() should return true afterthis method is called.○ Be careful about which member variables should be updated.Part 3 TestingUnlike previous labs/assignments you are not given any tests as a starting point. Youmust create your own tests to examine each method you implemented. These testscan be written inside Tester.java.Here is one potential testing strategy: create an empty SortedBinarySet. Then, checkits size, check whether it is empty. Then, start adding a few numbers to yourSortedBinarySet and make sure they are added properly (that is, they are in the sortedorder, the other Member variables reflect the changes, etc). Then, continue addingvalues to your SortedBinarySet till you go beyond its original capacity. Make sure youare not having any errors in this case and that the SortedBinarySet does indeed grow.Finally, test your clear method to see if all elements are removed from theSortedBinarySet.Dont forget: lab/assignment is due Tuesday night @ 11:59pm!如有需要,请加QQ:99515681 或邮箱:99515681@qq.com

添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导