Name (print): ________________________________ Section No: _____________________

Honor Code Acknowledgment (sign): _____________________________


Random Quiz 1

CPS 100, Fall 1996

5 points

Due: September 10, 1996


All quizzes are due at the beginning of class on the due date.

Problem: (5 points)

Complete the function Median below. Do not assume any other functions exist. If you want to Swap two elements, then you need to provide the code for swapping the two elements. You may include other functions if you want.
int Median( const Vector <int> & numbers, int size)
// precondition: assumes there is at least one integer in the vector
// postcondition: returns the middle value, the first middle value if
//                there are an even number of numbers.
//              Example: If the array contained:  3 9 8 3 7 6 7 6
//                 then 6 is the 4th value and 7 is the 5th value, both
//                 in the "middle" of 8 values, so 6 is returned.
{