diff --git a/Binärbaum.java b/Binärbaum.java index a1e3e49..7994d13 100644 --- a/Binärbaum.java +++ b/Binärbaum.java @@ -42,7 +42,9 @@ public class Binärbaum m.remove(Minimum); int Minimum2 = Minimum(m); + //ermittelt das Minimum für die Festlegung des linken Knotens Node n2 = m.get(Minimum2); + //entfernt das aktuelle Minimum m.remove(Minimum2); Node neu = new Node(' ', n1.Anzahl + n2.Anzahl); neu.links = n1; @@ -53,14 +55,45 @@ public class Binärbaum } public void ausgeben(Node n, String i){ if(n.links != null){ +//gibt Weertee aus und erstellt dabei Binärcode ausgeben(n.links, i + "0"); ausgeben(n.rechts, i + "1"); }else{ System.out.println(n.wert + " : " + i+ " Anzahl:" + n.Anzahl); -} + n.Binärcode = i; } +} +public void codieren(String text){ +for(int i = 0; i l){ +//setzt temporäres Minimum auf der ersten Stelle der ArrayList int minindex = 0; for(int i = 0; i