Name: ________________________________

Honor Code Acknowledgment: ___________________


Random Quiz # 5

CPS 100, Spring 1996

Due: February 2


Problem 1: Oboy (2 points)

Consider a list of integers in which the integers are stored in non-decreasing order and in which the integer k occurs exactly k times; these lists are called N-lists where N is the largest integer in the list. For example, a 4-list is (1,2,2,3,3,3,4,4,4,4) and a five list is a 4-list with (5,5,5,5,5) appended to the end.

Using big-Oh notation (in terms of N) what is the number of elements in an N-list? Justify your answer briefly.










Problem 2: Hautbois 2 (2 points)

If all occurrences of numbers less than N/2 are removed from an N-list, how many numbers are left (using big-Oh notation)? Justify your answer briefly.




Problem 3: PolyO (2 points)

A polynomial is a mathematical function such as x^3 - 3x^2 + 2x - 4 (or, in math-enabled HTML browsers x3 - 3x2 + 2x - 4). If this polynomial is p(x), then p(2) = -4. Write a class declaration for a C++ class Polynomial. This can be as minimal as you want, but should include comments indicating what your polynomial operations your class supports. The key is to document whatever your minimal class does.