mockmidterm2answers - CS 61B Mock Exam July 30, 2008...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 61B Mock Exam July 30, 2008 A Disclaimer: This is mock exam is designed to give you hints for your review. It by no means resembles the actual midterm and you should not use these questions as the only basis in your exam preparation. You have 45 minutes to complete this mock exam.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 61B Mock Exam July 30, 2008 A Problem 1 (Asymptotic Analysis) Suppose . Assume and are positive for all values of x. For each of the following statements, say whether it must be true or must be false or could be either: Either True Either False Either Problem 2 (Hashing) Suppose we have defined a hash set for storing elements of class MyClass with b buckets and chains implemented as linked lists. First, n different elements are stored in the table. Now we wish to store one more, called newElem, which is not equal to any of the others. We'd like to do it with as few comparisons (calls to MyClass.equals) between newElem and other elements as possible. Ordinarily we'd ensure this by choosing a very good MyClass.hashCode method. But there's a catch: a dastardly adversary is trying to make the number of comparisons as large as possible. In terms of n and b, what is the fewest possible number of comparisons it will take to add newElem to the table if: a) The adversary gets to choose MyClass.hashCode(), but then we get to choose newElem (knowing his
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

mockmidterm2answers - CS 61B Mock Exam July 30, 2008...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online