Home

About

Advanced Search

Browse by Discipline

Scientific Societies

E-print Alerts

Add E-prints

E-print Network
FAQHELPSITE MAPCONTACT US


  Advanced Search  

 
Computer Science 136 Exam 1 Sample exam
 

Summary: Computer Science 136 Exam 1
Sample exam
Possible answers
1. True/false statements (2 points each). Justify each answer with a sentence or two.
a. Free question from 2/28. Two instances of class Association in the structure
package are equal if and only if their keys are equal, regardless of their values.
True, because the equals() method for an Association behaves this way.
b. An instance variable declared as protected can be accessed by any method of the class
in which it is declared.
True. All instance variables can be accessed by any method of the class in
which it is declared.
c. A binary search can locate a value in a sorted Vector in O(log n) time.
True. We can apply the "divide and conquer" approach to halve the search
size at each step.
d. A binary search can locate a value in a sorted SinglyLinkedList in O(log n) time.
False. Since there is no direct access to the middle of the list, we cannot
apply a binary search.
e. A method with no precondition should return with its postcondition true every time it
is called.
True. No precondition implies that the method should work correctly for

  

Source: Albrecht, Jeannie - Computer Science Department, Williams College

 

Collections: Computer Technologies and Information Sciences