{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Fall 07 CS 100 Test 2

Fall 07 CS 100 Test 2 - DUKE UNIVERSITY Department of...

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

View Full Document Right Arrow Icon
DUKE UNIVERSITY Department of Computer Science Test 2: CompSci 100 Name (print): Community Standard acknowledgment (signature): value grade Problem 1 14 pts. Problem 2 9 pts. Problem 3 7 pts. Problem 4 12 pts. Problem 5 8 pts. TOTAL: 50 pts. This test has 8 pages, be sure your test has them all. Do NOT spend too much time on one question — remember that this class lasts only 50 minutes and there are 50 points on the exam. That means you should spend no more than 1 minute per point . You may consult your five (5) sheets and no other resources. You may not use any computers, calculators, or cell phones. You may refer to any program text supplied in lectures or assignments. Don’t panic. Just read all the questions carefully to begin with, and first try to answer those parts about which you feel most confident. Do not be alarmed if some of the answers are obvious. If you think there is a syntax error or an ambiguity in a problem’s specification, then please ask. In writing code you do not need to worry about specifying the proper import statements. Assume that all libraries and packages we’ve discussed are imported in any code you write.
Background image of page 1

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

View Full Document Right Arrow Icon
Test 2: CompSci 100 2 PROBLEM 1 : ( Short ones (14 points) ) 1. You are creating a boggle word search program and you want to find all valid words where the letters are adjacent. What data structure would be best suited to hold the dictionary (i.e. lexicon)? A. Queue B. Heap C. Trie D. AVL Tree E. Hash Table 2. In order to use the class Point containing fields x and y in a HashSet, you are considering multiple hash functions. Of these hash functions, which one would give the best performance in a HashSet ? Assume that your points are likely to be between (0, 0) and (1280, 1024) (the size of the average computer monitor). A. public int hashCode () { return super.hashCode(); } B. public int hashCode () { return 42; } C. public int hashCode () { return x; } D. public int hashCode () { return x + y; } E. public int hashCode () { return x * 3 + y; } F. public int hashCode () { return x * 1000 + y; } 3. True or False State whether the following statement is true or false. If false, you should give a specific counterexample. I. A certain hash table contains N integer keys, all distinct, and each of its buckets contains at most K elements. Assuming that the hashing function and the equality test require constant time, the time required to find all keys in the hash table that are between L and U is O ( K × ( U - L )) in the worst case. II. Instead of using a heap, we use an AVL tree to represent a priority queue. The worst-case big-Oh of add ( insert ) and poll ( deleteMin ) do not change.
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.
  • Fall '06
  • Astrachan
  • Computer Science, public int hashCode, Adam Alex Anna Cole Dave Ella Emma Eric Erik Erin Evan Hart Jack Jada Jake Jane Jeff Joey John Josh Kyle Leah Lily Luke Mark Mary Maya Noah Owen Ryan Sara Sean Seth Will, Adam Alex Cole Dave Erik Erin Evan Jack Jada Jane Jeff Kyle Luke Mary Noah Owen Sean Seth Abby Anna Ella Emma Eric Hart Jake Joey John Josh Leah Lily Mark Maya Ryan Sara Will, Dave Erik Erin Evan Jack Jada Jane Jeff Mary Noah Sean Luke Kyle Owen Seth Cole Alex Hart Mark Joey Emma Ella Lily Maya Leah Abby Anna John Ryan Josh Jake Sara

{[ snackBarMessage ]}

Page1 / 8

Fall 07 CS 100 Test 2 - DUKE UNIVERSITY Department of...

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

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