Programming and Problem Solving with Java

(やまだぃちぅ) #1

(^572) | Array-Based Lists
1.The list is empty.
2.The list contains one item.
3.The list contains more than one item.
4.The list contains the maximum number of items.
5.The list is already sorted in ascending order.
6.The list is already sorted in descending order.
We leave it as an exercise to convert this list into a complete test plan.
Testing and Debugging Hints
1.Review the testing and debugging hints from Chapter 10.
2.When the objects on the list are of simple types, their type names must be on
the parameter lists for isThere,insert, and delete.
3.When the objects on the list are of composite types, use Comparable in the pa-
rameter lists for the class name.
4.Verify that any argument to a list method with a Comparableparameter
belongs to a class that has implemented the Comparableinterface.
5.Be careful: arguments of primitive types cannot be passed to a method whose
parameter implements the Comparableinterface.
6.Test general-purpose methods outside the context of a particular application,
using a test driver.
7.Choose test data carefully so that you test all end conditions and some condi-
tions in the middle. End conditions reach the limits of the structure used to
store them. For example, a list test plan should include test data in which the
number of components is 0, 1, and the array size, as well as somewhere in
between.


Summary


This chapter provided practice in working with lists, where the items on the list are
stored in a one-dimensional array. We examined algorithms that insert, delete, and
search data stored in an array-based unsorted list, and we wrote methods to imple-
ment these algorithms. We also examined an algorithm that takes the array in which
the list items are stored and sorts them into ascending order.
We examined several search algorithms: sequential search in an unsorted list, se-
quential search in a sorted list, and binary search. The sequential search in an
Free download pdf