Sortieralgorithmen Flashcards

programm bezogen (7 cards)

1
Q

Wie ist der Konstruktor der Klasse Sortieren aufgebaut?

A
public class Sortieren
{
  private int[] a;
  
  public Sortieren()
  {
    a = new int[8];
    a[0]=4;
    a[1]=2;
    a[2]=1;
    a[3]=6;
    a[4]=3;
    a[5]=5;
    a[6]=6;
    a[7]=1;
    
    //erneuerung();
    }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Wie ist eine ausgabe Methode für einen Array aufgebaut?

A
public void ausgabeArray()
{
  for (int i = 0; i < a.length; i++) 
   {
      System.out.print(a[i] + " \t" );
   }  
    System.out.println();
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Wie ist der aufbau einer Erneuerungs Methode für einen Array?

A
public void erneuerung()
{
  for (int i = 0; i < a.length; i++) 
  {        a[i]=(int(Math.random()*90 + 10);
   }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Wie ist der aufbau einer Insertionsort Methode ?

Mit For(i1; <) und While, Wert Merken

A
public void insertionsort() 
{
    int wert;
    int stelle;
    for (int i = 1; i < (a.length); i++)
   {
      wert = a[i];
      stelle = i;
     while ( stelle > 0 && wert < a[stelle-1])
     { 
       a[stelle]= a[stelle-1];
       stelle = stelle-1;
     }
      a[stelle]= wert;
      ausgabeArray();
   }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Wie ist der aufbau einer Bubblesort Methode ?

do while und for (i0; <=)

A
public void bubblesort()
  {
    int wert;
    int liste;
    boolean tausch;
    liste = a.length; 
     do{
      tausch =false;
      for (int i = 0; i <= liste-2; i++)
      {
       if (a[i]<=a[i+1])
       {} 
       else
       {
        wert = a[i];
        a[i]= a[i+1];
        a[i+1]=wert;
        tausch=true;
       }
      } 
      liste = liste-1;
      ausgabeArray();
        }while(tausch == true);
  }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Wie ist der aufbau einer Selectionsort Methode ?

Mit Zwei For Schleifen(j0; <= ; -2)(i j+1; < ; -1) und stelle merken

A
public void selectionsort()
  {
    int zahl;
    for (int j = 0; j <= a.length-2; j++)
    {
      int stelle=j;
      for (int i = j+1; i < a.length-1; i++)
      {
        if (a[i] <= a[stelle])
        {
        stelle = i;
        }
      }
      zahl= a[stelle];
      a[stelle]=a[j];
      a[j]=zahl;   
      ausgabeArray();
    }
  }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Wie ist die Main Methode? der Klasse Sortieren aufgebaut?

A
public static void main(String[]arg)
  {
    Sortieren test1 = new Sortieren();
    test1.ausgabeArray();
    System.out.println();
    test1.selectionsort();
    
  }

  }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly