The George Washington University
School of Engineering and Applied Science
Department of Electrical Engineering and Computer Science
CSci 131 - Data Structures
Week 5 Homework
1. Explain why generic units are more likely to be reusable than nongeneric units.
2. Write a generic function that returns the smallest element of an array. The subscripts of the array should be an unconstrained range of integers. The components should be any ordered type.
3. Instantiate the function defined in problem 2 for both integer arrays and floating-point arrays.
4. Write a generic package specification to implement integer vectors of any length. Provide two operations: vector addition and vector subtraction. An exception should be raised for either operation if the vectors have different lengths. The elements of the vectors should be able to be any numeric type.
5. Instantiate the package defined in problem 4 for both integer vectors and for floating-point vectors.