Main points of this past exam are: Asymptotic Analysis, Same Input, Numerical Keys, Four-Node Tree, Node Tree, Binary Search, Search Tree, Valid Binary, Binary Heap, Possible Height
Download Asymptotic Analysis - Data Structures - Solved Exams and more Exams Data Structures and Algorithms in PDF only on Docsity!
CS 61B: Midterm II 1of4 CS 61B: Data Structures (pring 2005) Midterm II Solutions Problem 1. (8 points) Quickies. a. The worst-case time to find the second-smallest key in a 2-3-4 tree with n keys is @(log n). b. Algorithm A runs in O(n log n) worst-case time, and Algorithm B runs in Q(n?) worst-case time. It is not always true that Algorithm A takes less time than Algorithm B. There are at least two possible counterarguments (either of them worth full credit). First, on some inputs, Algorithm B might run much faster than its worst-case time. Second, the constants hidden in the asymptotic notation might be much smaller for Algorithm B than for Algorithm A, in which case Algorithm B might be much faster on small inputs. c. The line system.out.printIn(e); is acceptable. It calls e.toString();, and prints the string returned. (Note that toString is defined on all objects.) d. Q S) ORO http://www.cs.berkeley.edu/~jrs/61bs05/exam/05mid2.html Oo 2 &