$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

Next revision
Previous revision
notes:comp20007 [2021/05/12 00:56] – created, need to reformat algorithms joelegnotes:comp20007 [2023/05/30 22:32] (current) – external edit 127.0.0.1
Line 113: Line 113:
 === Pseudo-code === === Pseudo-code ===
  
-\begin{algorithm}[H] +<code> 
-\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}+</code>
  
 === Pre-order === === Pre-order ===
Line 242: 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.1620780976.txt.gz · Last modified: 2023/05/30 22:32 (external edit)