master
parent
354bf18a2c
commit
9774c8a91c
|
@ -5,6 +5,7 @@
|
||||||
* @author (Ihr Name)
|
* @author (Ihr Name)
|
||||||
* @version (eine Versionsnummer oder ein Datum)
|
* @version (eine Versionsnummer oder ein Datum)
|
||||||
*/
|
*/
|
||||||
|
import java.util.ArrayList;
|
||||||
public class Binärbaum
|
public class Binärbaum
|
||||||
{
|
{
|
||||||
//Attribute
|
//Attribute
|
||||||
|
@ -18,11 +19,28 @@ public class Binärbaum
|
||||||
//Konstruktor für inneren Knoten
|
//Konstruktor für inneren Knoten
|
||||||
|
|
||||||
public void einfügen(int [] Anzahl){
|
public void einfügen(int [] Anzahl){
|
||||||
|
//alle Nodes werden abgespeichert
|
||||||
|
ArrayList<Node> l = new ArrayList<Node>();
|
||||||
|
|
||||||
for(int i =0 ; i<Anzahl.length; i++){
|
for(int i =0 ; i<Anzahl.length; i++){
|
||||||
if(Anzahl[i] >= 1){
|
if(Anzahl[i] >= 1){
|
||||||
|
//Node wird angelegt
|
||||||
Node n = new Node((char)(i + 65), Anzahl[i]) ;
|
Node n = new Node((char)(i + 65), Anzahl[i]) ;
|
||||||
|
|
||||||
|
l.add(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Sortieren von den Werten mit Selection Sort
|
||||||
|
}
|
||||||
|
public int Minimum(ArrayList<Node> l){
|
||||||
|
int minindex = 0;
|
||||||
|
for(int i = 0; i<l.size(); i++){
|
||||||
|
//Vergleich Anfangsminimum und aktuellem Arraywert
|
||||||
|
if(l.get(minindex).Anzahl>l.get(i).Anzahl){
|
||||||
|
minindex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return minindex;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -9,9 +9,13 @@ public class List
|
||||||
{
|
{
|
||||||
public static int [] zählen(String text){
|
public static int [] zählen(String text){
|
||||||
int[] Anzahl = new int[26];
|
int[] Anzahl = new int[26];
|
||||||
|
//legt Array mit 26 Stellen an
|
||||||
for(int i = 0; i<text.length(); i++){
|
for(int i = 0; i<text.length(); i++){
|
||||||
|
//geht Array durch
|
||||||
int position = text.charAt(i) -65;
|
int position = text.charAt(i) -65;
|
||||||
|
//gibt Position in ASCII Tabelle zurück
|
||||||
Anzahl [position] ++;
|
Anzahl [position] ++;
|
||||||
|
//legt Anzahl der Buchstaben fest
|
||||||
}
|
}
|
||||||
return Anzahl;
|
return Anzahl;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue