Quiz 10
Version 1

 

 

Quiz for CS 5
Week 10

10. Suppose that datavals and speeds are two arrays declared, allocated, and initialized as:

double[] datavals = {1.2, 3.4, 4.5, 5.6},
         speeds = {0.0,1.0,2.0}; 
What does the statement
speeds = datavals 
do?

9. When insertion sort adds a new value to the sorted portion of the array, how does it make room in the array position where this value needs to be put?

8. What happens if you pass an array of longs to a method that is expecting an array of floats?

7. Give the names of five different algorithms for sorting an array.

6. How would you declare a six-dimensional array of floats named jointPositions?

5. Suppose that a method has the following header

public static short[] primes(int start) 
What type of value does it return?

4. Suppose that you want to initialize a 15 by 2 array using an explicit list of values. Do you use a list of two elements (each a list of length 15) or a list of 15 elements (each a list of length 2)?

3. What does it mean to say that an algorithm is an O(n^2) algorithm?

2. A two-dimensional array can be allocated all at once, or row-by-row. What sort of arrays can you create using the latter method, but not using the former?

1. Which is larger, for big values of n, n*log(n) or n*n (i.e. n squared)?

Last modified August 28 for Fall 99 cs5 by fleck@cs.hmc.edu


This page copyright ©1998 by Joshua S. Hodas. It was built with Frontier on a Macintosh . Last rebuilt on Thu, Nov 5, 1998 at 6:19:20 PM.
http://www.cs.hmc.edu/~hodas/courses/cs5/week_11/quiz.html