Homework 2 (SortedIntList) FAQ

Q: I don't understand binary search. What is it? Do I need to use it on this assignment? Where/why?
A: Yes, you need to use binary search. Read the description of indexOf for more details. You should use binary search in your add method to efficiently find out if a value is already in your list. If so, and if your list is not allowing duplicates, then you shouldn't add the value again. If the value isn't in the list, you need to insert it, and binary search also efficiently helps you discover where it should be inserted. You also need to use binary search in your indexOf method to efficiently search for elements. Binary search works only if the array is sorted. Again, look at the example calls in the indexOf section to see how Arrays.binarySearch is called, what it returns, and how to use its returned value properly.
Q: Why do I get a "cannot find symbol" compiler error when I try to use Arrays.binarySearch (or some other method of the Arrays class)?
A: Different versions of Java have different version of the Arrays class, only the most recent include the four parameter binary search method required for this assignment. Directions for installing this software are located in the Working at Home page of this site. If things are still not working for you (usually because you are on a Macintosh running the older Java version 1.5), try to update your Mac's version of Java by visiting the Apple OS X Java update site. Download the "Java for Mac OS X 10.5" and install it. Re-run your Java editor and try again. You may also need to set Eclipse to use the Java v1.6 rather than 1.5.

If all of that still doesn't work, you may need to download the Arrays.java file located on the Homework page under the files for this assignment. Save it into the same directory as your SortedIntList and ArrayIntList classes, compile it, and then try to use Arrays.binarySearch as before. If it still doesn't work, contact your TA.

Q: The testing code keeps giving me a certain error message. What does it mean?
A: You should direct this question to your TA, or ask at the IPL, or post to the course message board. Read the error message carefully to look for explanations of what is wrong or line numbers. If you can narrow down where the error is occurring, you can use the debug tools available in JGrasp or insert System.out.println commands to check for invalid states.
Q: Is passing the provided test cases enough to know I'll get a 20/20? Are they exhaustive?
A: Passing all of the test cases is a good indication that your class has the correct behavior, but no, they are not exhaustive. Your class is considered "correct" if it meets all of the specifications of the assignment write-up.
Q: The assignment spec tells the number of lines used in your sample solution. I don't have exactly that many. What have I done wrong? Will I be marked off?
A: You don't have to exactly match our line counts. They are just there as a sanity check. If your numbers are WAY off from ours, you may be solving the problem in the wrong way.