Fall 07 CS 100 Test 1

# Fall 07 CS 100 Test 1 - DUKE UNIVERSITY Department of...

This preview shows pages 1–4. Sign up to view the full content.

DUKE UNIVERSITY Department of Computer Science Test 1: CompSci 100 Name (print): Community Standard acknowledgment (signature): value grade Problem 1 9 pts. Problem 2 9 pts. Problem 3 6 pts. Problem 4 14 pts. Problem 5 12 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 four (4) 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 ﬁrst try to answer those parts about which you feel most conﬁdent. 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 speciﬁcation, 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.

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

View Full Document
Test 1: CompSci 100 2 PROBLEM 1 : ( Big-Oh (9 points) ) For each of the following, either indicate that it is true and brieﬂy tell why or give a counterexample. A. A O ( n ) algorithm is always preferable to a O ( n 2 ) algorithm. B. n log n + 4 n 2 O ( n 2 ) C. 3 n O (2 n )
Test 1: CompSci 100 3 PROBLEM 2 : ( Sets (9 points) ) A. What is log 2 1000 to the nearest integer? B. A set of values is maintained as a linked list, sorted in increasing order. What are the tightest asymptotic bounds you can give for the best and worst-case times for performing N insertions into this set, starting from an empty set? By tight bounds, we mean that if the program runs in time T ( n ), give O ( f ( n )) such that T ( n ) O ( f ( n )) and T ( n ) / o ( f ( n )). We want bounds for the worst-case time and bounds for the best-case time. C.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 04/27/2008 for the course COMPSCI 100 taught by Professor Astrachan during the Fall '06 term at Duke.

### Page1 / 8

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

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

View Full Document
Ask a homework question - tutors are online