Du befindest dich hier: FSI Informatik » Prüfungsfragen und Altklausuren » Prüfungen im Bachelor-Studium (1. - 5. Semester) » aud » Forendiskussionen

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.

Link zu der Vergleichsansicht

Beide Seiten, vorherige ÜberarbeitungVorherige Überarbeitung
Nächste ÜberarbeitungBeide Seiten, nächste Überarbeitung
pruefungen:bachelor:aud:loesung-miniklausur-14 [13.02.2016 14:22] – Forendiskussionen hinzugefuegt. dompruefungen:bachelor:aud:loesung-miniklausur-14 [28.03.2016 15:35] – Code vereinfacht Marcel[Inf]
Zeile 121: Zeile 121:
     {     {
         if( children[i] != null )         if( children[i] != null )
-            tmp = height( children[i] )+            max Math.max(max, height(children[i])+1);
-        if( max < tmp max = tmp;+
     }     }
-    if( tmp == -1 ) return 0; +    return max;
-    else return max + 1;+
 } }
 </code> </code>
Zeile 132: Zeile 130:
 <code java> <code java>
 static int longest(Tentree tree){ static int longest(Tentree tree){
-  +    // Basisfall 
 +    if (tree == null) { 
 +      return 0; 
 +    }
  
     int without = 0;      int without = 0; 
     int tmp = 0;     int tmp = 0;
-    for( int i = 0; i < 10; ++i )+    for ( int i = 0; i < 10; ++i )
     {     {
-        if( children[i] != null ) +        tmp = longest( children[i] );
-            tmp = longest( children[i] );+
         if( without < tmp )         if( without < tmp )
             without = tmp;             without = tmp;
Zeile 162: Zeile 162:
         }         }
     }     }
-    with += n + 2;+    if (n != 0) { // Mindestens zwei Pfade gefunden 
 +      with += n + 2; 
 +    } else { 
 +      with = 0; // zB nur ein Pfad => auf 0 zurücksetzen 
 +    }
     return Math.max(without, with);      return Math.max(without, with); 
 } }
 </code> </code>