notes:comp20007
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| notes:comp20007 [2021/05/12 04:36] – fixed algotithm joeleg | notes:comp20007 [2023/05/30 22:32] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 241: | Line 241: | ||
| ==== Algorithm ==== | ==== Algorithm ==== | ||
| - | \begin{algorithm}[H] | + | < |
| - | | + | For{i gets 0 to n} { |
| - | \For{i\gets0\text{ | + | K[i,0] gets 0 |
| - | K[i,0]\gets 0\\ | + | } |
| - | } | + | For{j gets 1 to W} { |
| - | \For{j\gets 1\text{ | + | K[0,j] gets 0 |
| - | K[0,j]\gets 0\\ | + | } |
| - | } | + | For{i gets 1 to n} { |
| - | \For{i\gets 1\text{ | + | For{j gets 1 to W} { |
| - | \For{j\gets 1\text{ | + | If{j< |
| - | \eIf{$j<w_i$}{ | + | K[i,j] gets K[i-1,j] |
| - | K[i,j]\gets K[i-1,j]\\ | + | } else { |
| - | }{ | + | K[i,j] gets max(K[i-i, |
| - | K[i,j]\gets max(K[i-i, | + | |
| - | } | + | |
| } | } | ||
| } | } | ||
| - | \Return{K[n, | + | } |
| - | \end{algorithm} | + | Return{K[n, |
| + | </ | ||
| ===== Binary Search tree ===== | ===== Binary Search tree ===== | ||
notes/comp20007.1620794183.txt.gz · Last modified: (external edit)