- How many distinct arrangements of n pairs of left-right parentheses are there all of which does?
- The n-th Catalan number, C(n)
C(1) = 1, ()
C(2) = 2 ()() and (())
C(3) = 5 ()()(), ()(()),(())(),((()))
At very last step, we compute (Ai × Ai+1 × ... × Ak) × (Ak+1 × ... × Aj) at some point k, i ≤ k < j So, the chain is split into these two subchains, that is, find the minimum number of multiplications for (Ai × Ai+1 × ... × Ak) and the one for (Ak+1 × ... × Aj). Thus, Cost(Ai...j) = min_k ( Cost(Ai...k) + Cost(Ak+1...j) + pi-1 * pk * pj )
Establish recursive property:
If i=j, then 0 If i<j, m[i][j] = min(m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j])
[step1] Create the table with rows(' ','c','a','t') and columns(' ','c','a','k','e') and compute edit distance when one side is null.
[step2] If the characters are same, take the value on left above
[step3] For other cases, take the minimum on values on left-above, left, and above and then increment by 1. 두 문자의 비교 결과가 서로 다를 때 (si ≠ tj) 이 경우에는 3가지 연산 중 하나를 선택: 1) 삽입 (Insert): 왼쪽 값 → d[i][j-1] 2) 삭제 (Delete): 위쪽 값 → d[i-1][j] 3) 교체 (Replace): 대각선 왼쪽 위 값 → d[i-1][j-1] 이 셋 중 가장 작은 값을 선택하고 +1을 더함 → 편집 연산 1회를 추가 의미.
d[8][8] = 3 이라는 뜻은: S = agaattgca를 T = acaagtga로 바꾸려면 최소 3번의 편집 연산이 필요.