Quiz 2 CSE 21 Spring 2012
Quiz 2 CSE 21 Spring 2012
Name_________________________ Score:
26 refrigerator magnets (A-Z). No duplicates. How many 9-letter strings can be formed from them? _____ A) P(26,9) B) C(26,9) C) 26! D) 926 E) 9! F) 269
Which of the following would require the use of strong induction and which would require the use of weak induction in a proof? A) strong induction B) weak induction _____ T(n) = 2*T(n-1) _____ T(n) = T(n-1) + T(n-2) _____ T(n) = T(n-1) + 7
Regarding the SList, Search, and BSearch defined in the textbook Which of the following recurrence relations best represents the number of comparisons required for the recursive linear search function Search(t,L) where n is the number of elements in list to be searched? _____ A) B: T(1) = 1; R: T(n) = 2*T(n/2) B) B: T(1) = 1; R: T(n) = 2*T(n-1) + 1 C) B: T(1) = 1; R: T(n) = T(n-1) + T(n-2) D) B: T(1) = 1; R: T(n) = T(n/2) + 1 E) B: T(1) = 1; R: T(n) = T(log2 n) + 1 F) B: T(1) = 1; R: T(n) = 2*T(n/2) + T(n-1)
Which of the above recurrence relations best represents the number of comparisons required for the recursive binary search function BSearch(t,L) where n is the number of elements in list to be searched? _____
How many 5-digit zip codes start with an odd digit and end with an even digit? _____ [Assume all decimal digits can be used in any position in a zip code; 0 is even.] A) (105 - 52) B) (105 / 52) C) (5!)/(2!) D) P(10,3) * P(5,2) E) C(10,3) * C(5,2) F) (52 * 103)
If 21 students are enrolled CSE 30 and 30 students are enrolled in CSE 21, how many different students are enrolled in these two classes if there are 10 students enrolled in both? _____ if there are no students enrolled in both? _____ A) 55 B) 46 C) 51 D) 41 E) 61 F) C(51,10) G) C(30,21)
An urn contains 10 balls numbered 1-10. Four balls are drawn from the urn as described below, and the numbers on the balls are recorded. How many ways are there to do this A) P(10,4) B) C(10,4) C) 4! D) 410 E) 104 F) 10! 6!
if the four balls are drawn one at a time and replaced before the next one is drawn? _____ if the four balls are drawn one at a time and not replaced before the next one is drawn? _____ if the four balls are drawn all at once? _____
Match the person to what the person is famous for. _____ Known as the father of analysis of algorithms _____ Invented Quicksort algorithm _____ Invented the shortest path algorithm _____ Conceptualized the idea of machine-independent programming languages, which led to the development of COBOL _____ Outspoken critic of the goto statement and BASIC; favored structured programming instead. A) C.A.R. Hoare B) Donald Knuth C) Edsger Dijkstra D) Grace Hopper
How many four-digit binary strings are there that do not contain 010 or 111? First draw the entire decision tree with 0s to the left and 1s to the right.
__
__
__
__
__
__
__
__
__
__
__
__
__
__
__
__
__
__
__
__
__
__
__
__
__
__
__
__
__
__
Now cross out leaf nodes of any string that contains 010 or 111 in its path. The remaining leaf nodes should be paths that do not contain 010 or 111. How many such four-digit binary strings do not contain 010 or 111? _____
How many different ways are there to distribute 14 identical bones among 4 different dogs? _____ A) C(17, 3) B) C(18,4) C) C(14,4) D) C(18,14) E) 14 * 4 F) 144 G) 414