notes:comp20007
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
notes:comp20007 [2021/05/12 00:56] – created, need to reformat algorithms joeleg | notes:comp20007 [2023/05/30 22:32] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 113: | Line 113: | ||
=== Pseudo-code === | === Pseudo-code === | ||
- | \begin{algorithm}[H] | + | < |
- | \DontPrintSemicolon | + | Inject(T) |
- | Inject(T)\; | + | While{data structure is non-empty} { |
- | \While{data structure is non-empty}{ | + | T gets eject |
- | T\gets eject\\ | + | If{T_{left} is non-empty} { |
- | \If{$T_{left}$ is non-empty}{ | + | Inject(T_{left}) |
- | Inject(T$_{left}$) | + | } |
- | } | + | If{T_{right} is non-empty} { |
- | \If{$T_{right}$ is non-empty}{ | + | Inject(T_{right}) |
- | Inject(T$_{right}$) | + | } |
- | } | + | |
} | } | ||
- | \end{algorithm} | + | </ |
=== Pre-order === | === Pre-order === | ||
Line 242: | 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.1620780976.txt.gz · Last modified: 2023/05/30 22:32 (external edit)