Mid-II-1a-sol - Midterm II, Part 1 Version A Nov. 16, 2011...

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

View Full Document Right Arrow Icon
Midterm II, Part 1 – Version A Nov. 16, 2011 2:00pm - 2:50pm CS431 CS531 (Please circle one) First Name (Print): Last Name (Print): UB ID number: 1. This is a closed book, closed notes exam. 2. You must support your answer. 3. Write your name on the top right-hand corner of every page. 4. There are 4 problems and 17 points in this exam. 0
Background image of page 1

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

View Full DocumentRight Arrow Icon
1. (5 points). Find the longest common subsequence (LCS) of the sequences X = < ACBAC > and Y = < AABC > . Fill out the 2D array c [0 ..m, 0 ..n ], where c [ i,j ] is de±ned to be the length of the LCS of X i and Y j . The entries of c [ , ] can be calculated by the following: c [ ] = 0 if i = 0 or j = 0 c [ i 1 , j 1] + 1 if x i = y j max { c [ i, j 1] , c [ i 1 ,j ] } if x i n = y j Show your answer by ±lling out the table c [ , ] by numbers and arrows. Also indicate the LCS of X and Y . 0 1 2 3 4 5 0 1 2 3 4 B A C A B C yj A C A xi Figure 1: LCS Table LCS of X and Y : 1
Background image of page 2
Answer: 0 1 2 3 4 y j A A B C 0 x i 0 0 0 0 0 1 A 0 տ 1 տ 1 1 1 2 C 0 1 1 1 տ 2 3 B 0 1 1 տ 2 2 4 A 0 տ 1 տ 2 2 2 5 C 0 1 2 2 տ 3 The LCS of X and Y is ABC.
Background image of page 3

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

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

Page1 / 7

Mid-II-1a-sol - Midterm II, Part 1 Version A Nov. 16, 2011...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online