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
- In insertion sort, the elements are shifted incorrectly. Shift the highest
index element first, then the next highest, and so forth.
- 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.
- Generic pointers should be used with care. In traditional C, use char
pointer instead of void pointer.