Name:     ID: 
 
    Email: 

CIS 260 Chapters 1-6

Multiple Choice
Identify the letter of the choice that best completes the statement or answers the question.
 

 1. 

Which of the following describes the fastest algorithm?
a.
O(n)
d.
O(n log n)
b.
O(nchapter1-6_files/i0020000.jpg)
e.
They are all slow
c.
O(log n)
 

 2. 

The concept of a type in a computer language includes all but which of the following?
a.
values
c.
properties
b.
operations
d.
capacities
 

 3. 

Which of the following is not a Java primitive type?
a.
boolean
c.
short
b.
integer
d.
double
 

 4. 

Given the Set ADT, which operation below will remove all elements of the argument set from the current set?
a.
unionWith
c.
intersectWith
b.
differenceWith
d.
subsetOf
 

 5. 

One category of containers remembers the order in which elements are inserted. Which one of the following is NOT in this category?
a.
Stack
c.
Queue
b.
Deque
d.
Bag
 

 6. 

A common technique used to prove termination of an algorithm is to indentify a property or value that possesses all but which one of the following?
a.
The property or value can be placed in a one-to-one correspondence with integer values.
c.
The property or value is nonnegative
b.
The property or value decreases steadily as the algorithm executes.
d.
The property or value must be initialized to a fixed maximum value prior to execution of the algorithm.
 

 7. 

Given the following code:

void mysterySort ( double [] v ) {
  int n = v.length;
  for (int i = 1; i < n; i++) {
    // move element v[i] into place
    double element = v[i];
    int j = i - 1;
    while (j >= 0 && element < v[j]) {
      v[j + 1] = v[j];  // slide old value over
      j = j - 1;
    }
    // place element into position
    v[j + 1] = element;
  }
}

What is the Big O runtime behavior?
a.
n
c.
n log n
b.
nchapter1-6_files/i0080000.jpg
d.
log n
 

 8. 

In Chapter 6 on the Vector Data Structure a number of operations were discussed. Which one of the following operations has a different O() worst case from the other three?
a.
addElementAt
c.
removeElementAt
b.
addLast
d.
removeLast
 



 
Submit          Reset Help