This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: longest common substring = 5 has to be consecutive. b. Given (same as previous problem) c. Subproblem T(I, j) = longest common susbstring of x[1. .i], y[1j] That and exactly in x[i] and y[j] We want max of I,j T(I,j) d. Recursive formulation T(I, j) = 1 + T(i-1, j-1) if x[i] = y[j] Else, 0 e. The code is the same as before, except else T[I, j] = 0, return max number in T 3. Optimal binary search trees a. Dictionary data structure Begin 5% Do 40% Else 8% End 4% If 10% Then 10% While 23% Use a BST structure End Do then Begin else if while Expected # comparisons = 1 90.04) + 2(0.4 + 0.1) + 3(0.05 + 0.08 + 0.1 + 0.23) Do Begin while If Else then End Avg = 2.18 b....
View Full Document
- Spring '08