Algorithmen Flashcards

1
Q

Clock Cycle

A

Is the time separating one process step of CPU from the next. The clock rate is corresponding frequency. Typical values are nowadays 0.3 ns and 3 GHz, respectively

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

Moore’s law

A

Is an empirical law stating that the power of CPUs increases by factor of 10 about every 6 years

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

Compiling a program

A

Translation of code into machine language, thereby producing a (binary) object file. The object file is just a translation of source file, it is not yet on its own executable

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

Liking a program

A

Will take all the objects files required by a program, possibly along with other object files gathered from libraries and uses these to produce a single file containing the executable program

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

A greedy algorithm

A

Solves a problem by always selecting the option yielding the largest immediate progress towards the goal

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

Rekursive Implementierung Struktur

A
Funktion deklarieren {
   If(n=1)
    Return 1;    Abbruchbedingung Bsp 
 Return n*funktion(n-1);        Auch Bsp 
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Sequential search Algorithmus

Falls kein Element gefunden wird retourniert 0

A
int sequentialSearch (int n[], int N, int goal) { 
    for (int i=0; i
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Sequential search „prigrammiertrick“

A

n[N] = goal setzen

Int SeqSearch (int n[], int N, int goal) { 
    n[N]=goal;
    int i = 0
    while (n[i] != goal) 
        i++
    Return i; 
} 

Resultat wird immer gefunden

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

Was ist ein Binary search?

A

Wir nehemen das mittlere Element und vergleichen, ob der zu suchende Wert größer, kleiner oder gleich diesem ist.
Man benutzt Arrays

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

Binary search Bsp. Code

A
Int BinSeach (int n[], int N, int goal) { 
   int left=0, right=N-1, middle; 
   while (left <= right) { 
      middle = (right + left) / 2;   //integer division 
      if (goal < n[middle]) 
         right = middle - 1; 
      else if (goal > n[middle]) 
         left = middle + 1;
      else 
         Return middle;
   } 
Return -1
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Wie wird ein sorrieralgorithmus der gleiche Elemente nucht vertauscht genannt

A

Stable

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

Wie funktioniert ein Selection Sort Algorithmus (Prinzip)

A
  1. Suche aus dem Array das kleinste Element
  2. Lege diesen an den Anfang
  3. Suche aus dem (noch nicht sortieren) Rest wiederum das kleinste Element)
  4. etc.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Selection Sort Algorithmus

A
Void selSort (int n[], int N) { 
//repeat this step as long as there are elements to sort 
   for (int i=0; i
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Was ist due anzahl vergleiche beim Selection sort argorithmus?

A

N(N-1)/2

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

Was ist die Anzahl Tauschoperationen beim Selection Sort Algorithmus (worst case)

A

N-1

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

Insertion Sort Code

A
Void insSort (int n[], int N) { 
//repeat as long as there are un sorted elements 
   for (int i=0; i 0 && n[j] < n[j-1]) {
//exchange the element 
         int temporary = n[j]; 
         n[j] = n[j-1]; 
         n[j-1] = temporary; 
//adapt the position of current element 
         j- - ; 
      } 
   } 
   return; 
}
17
Q

rectangular quadure integral approximation

A
double rectangular_quadure (double a, double b, int N) { 
   double sum = 0; 
   double h = (b - a)/N; 
   for (int i = 0; i
18
Q

trapetiodal_quadrature code

A
double tr_qu (double a, double b, int N){
   Double sum=0; 
   Double h=(b-a) / N 
   For (int i=0; i
19
Q

Was ist ein stable Algorithmus?

A

Ein Algorithmus der zwei Elemente mit der gleichen value in der gleichen Reihenfolge bleiben beim sortieren

20
Q

Swaping mechanismus mit a[i]

A

If (a[i] < a[i-1]) {
temp = a[i-1];
a[i-1] = a[i]
a[i] = temp