$conf['savedir'] = '/app/www/public/data'; notes:comp20007 [DokuWiki]

Site Tools


notes:comp20007

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
notes:comp20007 [2021/05/12 04:36] – fixed algotithm joelegnotes:comp20007 [2023/05/30 22:32] (current) – external edit 127.0.0.1
Line 241: Line 241:
 ==== Algorithm ==== ==== Algorithm ====
  
-\begin{algorithm}[H] +<code> 
-  \DontPrintSemicolon +For{i gets 0 to n} { 
-  \For{i\gets0\text{ to }$n$}{ +  K[i,0] gets 0 
-    K[i,0]\gets 0\\ +
-  +For{j gets 1 to W} { 
-  \For{j\gets 1\text{ to }$W$}{ +  K[0,j] gets 0 
-    K[0,j]\gets 0\\ +
-  +For{i gets 1 to n} { 
-  \For{i\gets 1\text{ to }$n$}{ +  For{j gets 1 to W} { 
-    \For{j\gets 1\text{ to }$W$}{ +    If{j<w_i}{ 
-      \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,j],K[i-1,j-w_i]+v_i)
-        K[i,j]\gets max(K[i-i,j],K[i-1,j-w_i]+v_i)\\ +
-      }+
     }     }
   }   }
-  \Return{K[n,W]} +
-\end{algorithm}+Return{K[n,W]} 
 +</code>
 ===== Binary Search tree ===== ===== Binary Search tree =====
  
notes/comp20007.1620794183.txt.gz · Last modified: 2023/05/30 22:32 (external edit)