CS 222   Fall 2005,  Instructor:  Jeffrey Horn                       HOMEWORK 3 (program 2)   BINARY SEARCH


DESCRIPTION

Package up the binary search code we developed in class.   Include both the iterative and the recursive versions.  Implement the "list" ADT in a class with member methods/functions for the ADT operations "insert", "delete", and "member".  Write test code in your "main" to create an object of your class and test it.  Use a large (10000 elements) file of input to test your data.  Write a small piece of code to generate the file of random values.  Choose any one of the following data types for searching:  int, float, double, string.   Sorting?  Yes you need a sorted array for binary search to work, but don't bother to write a sort method.  Instead, just make sure that your "insert" method inserts into the array in sorted order.  In other words, it finds where to insert the new element (you can use your binary search code to do this quickly!) and then shift right a portion of the array to allow the insert.   Your code can allow duplicates (essentially by ignoring them) or it can detect them before insertion and simply not allow them.  You may choose how to handle duplicates.  But you must say in your comments how you handle them.  Feel free to generate console messages warning about duplicates, but do not stop executing just because of that!

SPECIFICS