Previous: 10.5 Polymorphic Data Type
Up: 10 Sorting and Searching
Next: 10.7 Summary
Previous Page: 10.5 Polymorphic Data Type
Next Page: 10.7 Summary

10.6 Common Errors

  1. In insertion sort, the elements are shifted incorrectly. Shift the highest index element first, then the next highest, and so forth.

  2. The argument in binary search that specifies the high index is incorrect. If the size of the array is passed as the highest index, there is a problem. If the size of the array is n, the index n is outside the array. The argument should be n - 1.

  3. Generic pointers should be used with care. In traditional C, use char pointer instead of void pointer.

tep@wiliki.eng.hawaii.edu
Sat Sep 3 06:58:41 HST 1994