<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  <link rel="stylesheet" type="text/css" media="all" href="stylesheet.css">
  <title>Lösungen</title>
</head>
<body>
  <span id="menu"><a href="index.php">zurück zur Liste</a></span>
  
  <div id="buttons">
    <form action="edit.php" method="POST">
      <input type="hidden" name="filename" value="<?php echo $_SERVER['SCRIPT_FILENAME']?>">
      <p>
        <input type="submit" value="Seite bearbeiten">
      </p>
    </form>
  </div>
  
  <h1>Lösungen</h1>
  
  <h2>Vollständige Induktion</h2>
  <table>
  <tr>
    <td>1. </td>
    <td><b>Induktionsanfang</b></td>
    <td>A(1): 1 = 1<sup>2</sup></td>
  </tr>
  <tr>
    <td></td>
    <td><b>Induktionsvoraussetzung</b></td>
    <td>A(n): 1 + 3 + 5 + ... + (2n - 1) = n<sup>2</sup></td>
  </tr>
  <tr>
    <td></td>
    <td><b>Induktionsbehauptung</b></td>
    <td>A(n+1): 1 + 3 + 5 + ... + (2n - 1) + (2(n+1) - 1) = (n+1)<sup>2</sup></td>
  </tr>
  <tr>
    <td></td>
    <td><b>Induktionsschritt</b></td>
    <td>n &#8594; n+1<br>
        1 + 3 + 5 + ... + (2n - 1) + (2(n+1) - 1) = (n+1)<sup>2</sup><br>
        n<sup>2</sup> + (2n + 1) = n<sup>2</sup> + 2n + 1 mit IV
    </td>
  </tr>
  </table>

  <table>
  <tr>
    <td>2. </td>
    <td><b>Induktionsanfang</b></td>
    <td>[] ++ [] = []</td>
  </tr>
  <tr>
    <td></td>
    <td><b>Induktionsvoraussetzung</b></td>
    <td>x ++ [] = x</td>
  </tr>
  <tr>
    <td></td>
    <td><b>Induktionsbehauptung</b></td>
    <td>a:x ++ [] = a:x</td>
  </tr>
  <tr>
    <td></td>
    <td><b>Induktionsschritt</b></td>
    <td>l &#8594; l+1, also x &#8594; a:x<br>
        a:x ++ [] = a:x<br>
        a:(x ++ []) = a:x mit (a)<br>
        a:x = a:x mit IV<br>
    </td>
  </tr>
  </table>

  <table>
  <tr>
    <td>3. </td>
    <td><b>Induktionsanfang</b></td>
    <td>rev ([] ++ b) = (rev b) ++ (rev [])<br>
        rev b = (rev b) ++ [] mit (2a), (2)<br>
        rev b = rev b mit (2a)</td>
  </tr>
  <tr>
    <td></td>
    <td><b>Induktionsvoraussetzung</b></td>
    <td>rev (a ++ b) = (rev b) ++ (rev a)</td>
  </tr>
  <tr>
    <td></td>
    <td><b>Induktionsbehauptung</b></td>
    <td>rev ((x:a) ++ b) = (rev b) ++ (rev x:a)</td>
  </tr>
  <tr>
    <td></td>
    <td><b>Induktionsschritt</b></td>
    <td>l &#8594; l+1, also a &#8594; x:a<br>
        rev ((x:a) ++ b) = (rev b) ++ (rev x:a)<br>
        rev (x:(a ++ b)) = (rev b) ++ (rev a) ++ [x] mit (2b), (b)<br>
        rev (a ++ b) ++ [x] = (rev b) ++ (rev a) ++ [x] mit (b)<br>
        rev (a ++ b) ++ [x] = rev (a ++ b) ++ [x] mit IV<br>
    </td>
  </tr>
  </table>

  <table>
  <tr>
    <td>4. </td>
    <td><b>Induktionsanfang</b></td>
    <td>rev (rev []) = []<br>
        rev [] = [] mit (a)<br>
        [] = [] mit (a)
    </td>
  </tr>
  <tr>
    <td></td>
    <td><b>Induktionsvoraussetzung</b></td>
    <td>rev (rev xs) = xs</td>
  </tr>
  <tr>
    <td></td>
    <td><b>Induktionsbehauptung</b></td>
    <td>rev (rev x:xs) = x:xs</td>
  </tr>
  <tr>
    <td></td>
    <td><b>Induktionsschritt</b></td>
    <td>l &#8594; l+1, also xs &#8594; x:xs<br>
        rev (rev x:xs) = x:xs<br>
        rev ((rev xs) ++ [x]) = x:xs mit (b)<br>
        (rev [x]) ++ (rev (rev xs)) = x:xs mit (3)<br>
        (rev [x]) ++ xs = x:xs mit IV<br>
        [x] ++ xs = x:xs mit (c)<br>
        x:[] ++ xs = x:xs mit (d)<br>
        x:([] ++ xs) = x:xs mit (2b)<br>
        x:xs = x:xs mit (2a)
    </td>
  </tr>
  </table>

  <h2>Primitiv rekursive Funktionen</h2>  
  <table>
      <tr>
        <td>
          Aufstellen der Gleichungen &#8594; 
        </td>
        <td>
          Einfache Lösungen &#8594; 
        </td>
        <td>
          Gleichungen mit <b>&#968;</b> und <b>&#967;</b>
        </td>
      </tr>
      <tr>
        <td>
          <b>pred</b> (0)<br>
          <b>pred</b> (n+1)
        </td>
        <td>
          = 0<br>
          = n
        </td>
        <td>
          = <b>clr</b> ()<br>
          = <b>p2</b> (pred (n), n)
        </td>
      </tr>
      <tr>
        <td>
          <b>eq0</b> (0)<br>
          <b>eq0</b> (n+1)
        </td>
        <td>
          = 1<br>
          = 0
        </td>
        <td>
          = <b>suc clr</b> ()<br>
          = <b>clr</b> (eq0 (n), n)
        </td>
      </tr>
      <tr>
        <td>
          <b>sub</b> (0, m)<br>
          <b>sub</b> (n+1, m)
        </td>
        <td>
          = m<br>
          = pred (n, m)
        </td>
        <td>
          = <b>p1</b> (m)<br>
          = <b>pred p1</b> (sub (n, m), n, m)
        </td>
      </tr>
      <tr>
        <td>
          <b>and</b> (0, m)<br>
          <b>and</b> (n+1, m)
        </td>
        <td>
          = 0<br>
          = m
        </td>
        <td>
          = <b>clr</b> (m)<br>
          = <b>p3</b> (and (n, m), n, m)
        </td>
      </tr>
      <tr>
        <td>
          <b>not</b> (0)<br>
          <b>not</b> (n+1)
        </td>
        <td>
          = 1<br>
          = 0
        </td>
        <td>
          = <b>suc clr</b> ()<br>
          = <b>clr</b> (not (n), n)
        </td>
      </tr>
      <tr>
        <td>
          <b>ge</b> (0, m)<br>
          <b>ge</b> (n+1, m)
        </td>
        <td>
          = eq0 (m)<br>
          = eq0 (sub (n+1, m))
        </td>
        <td>
          = <b>eq0</b> (m)<br>
          = <b>eq0 (sub (suc p2, p3))</b> (ge (n, m), n, m)
        </td>
      </tr>
      <tr>
        <td>
          <b>if</b> (0, m<sub>1</sub>, m<sub>2</sub>)<br>
          <b>if</b> (n+1, m<sub>1</sub>, m<sub>2</sub>)
        </td>
        <td>
          = m<sub>2</sub><br>
          = m<sub>1</sub>
        </td>
        <td>
          = <b>p2</b> (m<sub>1</sub>, m<sub>2</sub>)<br>
          = <b>p3</b> (pred (n, m<sub>1</sub>, m<sub>2</sub>), n, m<sub>1</sub>, m<sub>2</sub>)
        </td>
      </tr>
  </table>

<h2>O-Notation</h2>
<ol>
  <li>log<sub>2</sub> n < &#8730;n < n < n(log<sub>2</sub> n)<sup>2</sup> < n<sup>2</sup> < n<sup>3</sup> < 1,8<sup>n</sup> < 3<sup>n</sup></li>
  <li>(a) &#920;(n<sup>2</sup>)<br>
      (b) &#920;(n log<sub>2</sub> n)<br> 
      (c) &#920;(n · 4<sup>n</sup>)</li>
</ol>

<h2>Algorithmen</h2>
<ol>
  <li><b>Dijkstra:</b> D(a)=0, D(b)=2, D(c)=6, D(d)=8, D(e)=9, D(f)=9, D(g)=8, D(h)=12, D(i)=9</li>
  <li>Folgende Kanten sind im <b>kleinsten aufspannenden Baum</b> enthalten: (a,b), (b,c), (c,d), (d,e), (d,i), (e,f), (e,h), (i,g) </li>
  <li><b>Ein Huffman-Code:</b> A = 00, B = 110, C = 0100, D = 0101, I = 101, L = 0110, M = 0111, R = 111, S = 100</li>
  <li><b>Verschiebefunktion:</b></li>
</ol>
<table>
  <tr>
    <td>
      Wort <br>
      Stelle <br>
      Verschiebefunktion f 
    </td>
    <td>
      abacabb <br>
      1234567 <br>
      0112112
    </td>
  </tr>
</table>
<br>

<table>
  <tr>
    <td><b>a</b></td>
    <td><b>b</b></td>
    <td><b>b</b></td>
    <td><b>a</b></td>
    <td><b>b</b></td>
    <td><b>a</b></td>
    <td><b>b</b></td>
    <td><b>c</b></td>
    <td><b>a</b></td>
    <td><b>b</b></td>
    <td><b>a</b></td>
    <td><b>b</b></td>
    <td><b>c</b></td>
    <td><b>a</b></td>
    <td><b>b</b></td>
    <td><b>b</b></td>
    <td><b>b</b></td>
    <td><b>c</b></td>
    <td><b>a</b></td>
  </tr>
  <tr>
    <td>b<br>X</td>
    <td>a<br></td>
    <td>b<br></td>
    <td>c<br></td>
    <td>a<br></td>
    <td>b<br></td>
    <td>b</td>
    <td></td><td></td><td></td><td></td><td></td><td></td>
    <td></td><td></td><td></td><td></td><td></td><td></td>
    <td><br>f(1) = 0</td>
  </tr>
  <tr>
    <td></td>
    <td>b<br>-</td>
    <td>a<br>X</td>
    <td>b<br></td>
    <td>c<br></td>
    <td>a<br></td>
    <td>b<br></td>
    <td>b</td>
    <td></td><td></td><td></td><td></td><td></td><td></td>
    <td></td><td></td><td></td><td></td><td></td>
    <td><br>f(2) = 1</td>
  </tr>
  <tr>
    <td></td>
    <td></td>
    <td>b<br>-</td>
    <td>a<br>-</td>
    <td>b<br>-</td>
    <td>c<br>X</td>
    <td>a<br></td>
    <td>b<br></td>
    <td>b</td>
    <td></td><td></td><td></td><td></td><td></td>
    <td></td><td></td><td></td><td></td><td></td>
    <td><br>f(4) = 2</td>
  </tr>
  <tr>
    <td></td><td></td>
    <td></td><td></td>
    <td><i>b</i></td>
    <td>a<br>-</td>
    <td>b<br>-</td>
    <td>c<br>-</td>
    <td>a<br>-</td>
    <td>b<br>-</td>
    <td>b<br>X</td>
    <td></td><td></td><td></td><td></td>
    <td></td><td></td><td></td><td></td>
    <td><br>f(7) = 2</td>
  </tr>
  <tr>
    <td></td><td></td><td></td><td></td><td></td>
    <td></td><td></td><td></td><td></td>
    <td><i>b</i></td>
    <td>a<br>-</td>
    <td>b<br>-</td>
    <td>c<br>-</td>
    <td>a<br>-</td>
    <td>b<br>-</td>
    <td>b<br>-</td>
    <td></td><td></td><td></td>
    <td><br>Wort gefunden</td>
  </tr>
</table>

<h2>Graphen und Bäume</h2>
<ol>
  <li><b>AVL-Baum</b><br>
      <img src="avlbaumloesung.gif"><br>
      <img src="avlbaumloesung1.gif">
      <img src="avlbaumloesung2.gif">
      <img src="avlbaumloesung3.gif">
  </li>
  <li><b>B-Baum</b><br>
      <img src="bbaumloesung.gif">
  </li>
  <li><b>Rot-Schwarz-Baum</b> in eine (2,4)-Baum umgewandelt:<br>
      <img src="2-4baum.gif">
  </li>
  <li><b>Suffixbaum</b> von ananas$<br>
      <img src="ananas.gif">
  </li>
  <li><b>Adjazenzliste</b><br>
      <table>
        <tr>
          <td><b>u</b></td>
          <td>&#8594;</td>
          <td>v &#8594; x</td>
        </tr>
        <tr>
          <td><b>v</b></td>
          <td>&#8594;</td>
          <td>y</td>
        </tr>
        <tr>
          <td><b>w</b></td>
          <td>&#8594;</td>
          <td>y &#8594; z</td>
        </tr>
        <tr>
          <td><b>x</b></td>
          <td>&#8594;</td>
          <td>v</td>
        </tr>
        <tr>
          <td><b>y</b></td>
          <td>&#8594;</td>
          <td>x</td>
        </tr>
        <tr>
          <td><b>z</b></td>
          <td>&#8594;</td>
          <td>z</td>
        </tr>
      </table>

      <b>Adjazenzmatrix</b><br>
      <table>
        <tr>
          <td>nach</td>
          <td></td>
          <td><b>u</b></td>
          <td><b>v</b></td>
          <td><b>w</b></td>
          <td><b>x</b></td>
          <td><b>y</b></td>
          <td><b>z</b></td>
        </tr>
        <tr>
          <td></td>
          <td><b>u</b></td>
          <td>0</td>
          <td>1</td>
          <td>0</td>
          <td>1</td>
          <td>0</td>
          <td>0</td>
        </tr>
        <tr>
          <td></td>
          <td><b>v</b></td>
          <td>0</td>
          <td>0</td>
          <td>0</td>
          <td>0</td>
          <td>1</td>
          <td>0</td>
        </tr>
        <tr>
          <td>von</td>
          <td><b>w</b></td>
          <td>0</td>
          <td>0</td>
          <td>0</td>
          <td>0</td>
          <td>1</td>
          <td>1</td>
        </tr>
        <tr>
          <td></td>
          <td><b>x</b></td>
          <td>0</td>
          <td>1</td>
          <td>0</td>
          <td>0</td>
          <td>0</td>
          <td>0</td>
        </tr>
        <tr>
          <td></td>
          <td><b>y</b></td>
          <td>0</td>
          <td>0</td>
          <td>0</td>
          <td>1</td>
          <td>0</td>
          <td>0</td>
        </tr>
        <tr>
          <td></td>
          <td><b>z</b></td>
          <td>0</td>
          <td>0</td>
          <td>0</td>
          <td>0</td>
          <td>0</td>
          <td>1</td>
        </tr>
      </table>
      Eine Adjazenzliste ist hier sinnvoller, da bei der Adjazenzmatrix sehr viel Speicherplatz unnötig besetzt ist.
  </li>
  <li><b>Konvexe Hülle</b><br> besteht aus den Punkten A, D, G und H.</li>
  <li><b>Pre- und Postorder</b><br>
      (a)<br><img src="prepost1.gif"><br>
      Preorder : - + 2 * 3 6 / 4 1<br>
      Postorder: 2 3 6 * + 4 1 / -<br>
      (b)<br><img src="prepost2.gif"><br>
      Preorder : + - * 5 + 6 2 / 7 4 * 2 5<br>
      Postorder: 5 6 2 + * 7 4 / - 2 5 * +<br>
      (c)<br>
      Preorder : * 2 + 7 / 5 5<br>
      Inorder  : 2 * (7 + 5 / 5)<br>
      Postorder: 2 7 5 5 / + *
  </li>
</ol>
  
</body>
</html>