Download Breadth-First Search - Data Structures - Solved Exams and more Exams Data Structures and Algorithms in PDF only on Docsity!
CS 61B: Midterm II 1of3 CS 61B: Data Structures (pring 2009) Midterm II Solutions Problem 1. (12 points) A Miscellany. a. b. BException. c. Alpha-beta search prunes nodes N, H, Q, and R. d. 999. (Note that even if G contains self-edges, breadth-first search never creates a self-edge in T, because it never visits a node twice.) e. 1. f. No. Because f(n) € O(g(n)), there exist positive constants c and N such that f{n) = c g(n) for alln > N. Because h(n) € Q(n -g(n)), there exist positive constants d and P such that h(n) =dng(n) foralln>P. Suppose that f(n) € @(h(n)). Then there exist positive constants e and M such that f(n) = e h(n) for alln > M. Putting these three together, we have that f(n) = ed n g(n) = (ed /c) n f{n) for alln > max{M, N, P}. In other words, n < c / (ed) for all n > max{M, N, P}, which is impossible. Problem 2. (6 points) Trees. a. http://www.cs.berkeley.edu/~jrs/61bs09/exam/09mid2.html