Computer Science 125 - 002 November 3, 1998 Second Exam
1. In the following, you are to define a portion of a Circle class (that does not invlolve any graphics). Include the following items:
2. The following technique was used by a software company:
Users who installed a product from the company were invited to run a supplied program to generate a mailing label for product registration. The software scanned the user's disk for all products which were produced by the company and included the encoded inventory information on the label (users were not informed of its exact behavior). The company then used the information to trace and pursue people who had illegally installed its software.
Do you think that the above practice was a violation of privacy rights? Support your position. [12 points]
3. The following function does a linear search of in integer array through a specified number of elements for a value which is passed as a parameter and returns the index where found or -1 if not found.
public int LSearch(int[] a, int count, int value) { int index = 0; while (index < count) { if (a[i] == value) return index; else index++; } return -1; }
If the arrary a is in ascending order, then the above can be improved slightly so that unsuccessful searches are generally somewhat better. Make the required changes (DO NOT turn it into a binary search). [10 points]
4. Given the following problem statement, circle the words (or phrases) which are candidates for the major classes in the problem. Also underline items which are good candidates for methods and for each such item, draw an arrow to the class in which it should be placed. Problem statement: [14 points]
Design a program which performs additions and multiplications with polynomials. A polynomial will consist of one or more terms where a term consists of a nonzero coefficient and a nonnegative integer exponent.
5. Testing is an important activity in system development [8 points each].
(a) Differentiate between black-box and white-box unit testing.
(b) Each of the methods in (a) tend to expose different kinds of errors. For one of the techniques, indicate a (type of) problem which it may be more effective at exposing than the other.
6. Write a function named Transpose which takes a two-dimensional
double array
parameter, creates, and returns the transpose of its
parameter. The transpose of an MxN array is
an NxM array for which an entry in the (i,j) position comes
from the (j,i) position from the other matrix. For example,
the transpose of
[14 points]
7. Draw a picture showing all of the storage cells associated with the statement: [10 points]
int[][][] a = new int[2][3][2];