Computer Science 61B - Fall 2001 - Hilfinger - Midterm 2

Computer Science 61B - Fall 2001 - Hilfinger - Midterm 2 -...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: file:///C|/Documents%20and%20Settings/Jason%20Raftery/My%20Doc...%2061B%20-%20Fall%202001%20-%20Hilfinger%20-%20Midterm%202.htm CS61B, Fall 2001, Test #2, Prof Hilfinger 1. The time (number of comparisons) required to insert into a binary search tree that contains N nodes is: a. always BigOmega(N) b. BigOmega(N) in the worst case. c. always bigO(N) d. bigTheta(N) in the worst case. e. always bigOmega(lgN) f. b and c g. b,c,d,e h. c and e 2. If an array containing N items starts out in ascending order and is then modified by swapping 10 pairs of items, then in the worst case, what can you say about the asymptotic times required by the algorithms discussed in class and in teh book? a. insertion-sorting the result will require bigOmega(N^2) time b. heap-sorting the result will require bigO(N^2) time. c. merge-sorting the result will be faster than insertion-sorting it. d. heap-sorting the result will be faster than insertion-sroting it. e. a, c, d f. a and c g. a and d 3. If program A requires bigTheta(N^2) time to perform its calculation on inputs of size N in the worst case and algorithm B requires bigTheta(100N) time in the worst case, then a. B takes less time in the worst case, and is therefore the algorithm to use for any application b. B takes less time as long as N > 100 c. if there is a max size input your program has to deal with, then either A or B might be preferable d. b and c 4. Suppose that we have a linked list of records with strings of letters 'a' through 'z' as keys, where there are N records, and the longest key has length L. a. LSD radix sort will be substantially faster on this data set if the records are already sorted. b. the worst case for MSD radix sort will occur if all keys are the same. c. if all the keys are distinct, then L >= log(base26)N. d. in the worst case, insertion sort will require bigO(N^2) machine instructions. e. in the worst case, insertion sort will require bigOmega((N^2)L) machine instructions. f. a, b, c g. b, c, d h. b, c, e i. a, c, e 5. Consider a hash table containing N keys. Assume that the hash fuction requires bigO(1) time, and that it maps equal numbers of these keys (+1,-1) to each bucket number, regardless of the number of buckets. file:///C|/Documents%20and%20Settings/Jason%20Rafte...20Fall%202001%20-%20Hilfinger%20-%20Midterm%202.htm (1 of 9)1/27/2007 6:31:33 PM file:///C|/Documents%20and%20Settings/Jason%20Raftery/My%20Doc...%2061B%20-%20Fall%202001%20-%20Hilfinger%20-%20Midterm%202.htm Assume also that the table's load factor is bounded by a constant. a. if the hash table uses external chaining, then the total cost of adding all N keys to the table and then performing K additional look-up operations is bigO(N+K)....
View Full Document

This note was uploaded on 05/17/2009 for the course CS 61B taught by Professor Canny during the Spring '01 term at Berkeley.

Page1 / 9

Computer Science 61B - Fall 2001 - Hilfinger - Midterm 2 -...

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