Homework 1: Resizable Arrays and Sorting
- Complete the implementation of the WordArray
class.
- The
contains() method should implement binary search.
- The
resize() method should double the array capacity each time.
- Write a class called
InsertInPlaceArray that extends WordArray and implements the
add() method. Each addition should maintain the sorted ordering.
- Write a class called
SortOnDemandArray that also extends WordArray. It should add elements by appending them to the end of the
array (calling resize() as needed). It should sort the array
(using an object that extends the Sorter class)
only as needed.
- Implement the classes
BubbleSorter, SelectionSorter, InsertionSorter, and MergeSorter. Use these classes to test SortOnDemandArray.
- Write a test program that can be used to test any variant of
WordArray.
- In your project in Eclipse, create packages called "wordlist" and "sorters". Place
WordArray in the wordlist package and
Sorter in the sorters package.
- The files data.txt and requests.txt may be useful for testing.
Submitting your solution
Submit your solution using Sauron. If
you have trouble using Sauron, you may email me your solution.