Compare commits

..

No commits in common. "93a20fb4dab84c0a29088e846096870360bded0e" and "be3cb9e2fc990dfb59339906999dba861e097970" have entirely different histories.

11 changed files with 5 additions and 83 deletions

BIN
bintree.o

Binary file not shown.

BIN
doble.exe

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,5 @@
player_name;4993
player_name;4992
player_name;4990
player_name;4953
player1;3999

BIN
main.o

Binary file not shown.

View File

@ -16,18 +16,6 @@ static int compareUInt(const void *a, const void *b)
return 0;
}
// --- Hilfsfunktion: Shuffle des Arrays (Fisher-Yates) ------------------
static void shuffle(unsigned int *array, unsigned int len)
{
for (unsigned int i = len - 1; i > 0; i--)
{
unsigned int j = rand() % (i + 1);
unsigned int temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
// Gibt ein Array mit len zufälligen Zahlen zwischen 1 und 2*len zurück, die alle unterschiedlich sind,
// außer zwei Einträgen (ein Duplikat). Verwendet den Binärbaum, um Duplikate zu vermeiden.
unsigned int *createNumbers(unsigned int len)
@ -66,9 +54,6 @@ unsigned int *createNumbers(unsigned int len)
unsigned int duplicateIndex = rand() % (len - 1);
arr[len - 1] = arr[duplicateIndex];
// Shuffle das Array, damit das Duplikat nicht immer am Ende steht
shuffle(arr, len);
// Baum freigeben
clearTree(root);
return arr;

BIN
numbers.o

Binary file not shown.

BIN
stack.o

Binary file not shown.

View File

@ -1,68 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "bintree.h"
// Hilfsfunktion: Vergleich von int
static int compareInt(const void *a, const void *b) {
int ia = *(const int *)a;
int ib = *(const int *)b;
if (ia < ib) return -1;
if (ia > ib) return 1;
return 0;
}
int main() {
printf("===== TEST BINTREE =====\n");
TreeNode *root = NULL;
int isDup;
// Test 1: addToTree - Einfügen eindeutiger Werte
int val1 = 10, val2 = 5, val3 = 15;
root = addToTree(root, &val1, sizeof(int), compareInt, &isDup);
if (isDup != 0) { printf("FAIL: Erstes Einfügen sollte kein Duplikat sein\n"); return 1; }
root = addToTree(root, &val2, sizeof(int), compareInt, &isDup);
if (isDup != 0) { printf("FAIL: Zweites Einfügen sollte kein Duplikat sein\n"); return 1; }
root = addToTree(root, &val3, sizeof(int), compareInt, &isDup);
if (isDup != 0) { printf("FAIL: Drittes Einfügen sollte kein Duplikat sein\n"); return 1; }
printf("PASS: addToTree - eindeutige Werte\n");
// Test 2: addToTree - Duplikat hinzufügen
int dup = 10;
root = addToTree(root, &dup, sizeof(int), compareInt, &isDup);
if (isDup != 1) { printf("FAIL: Duplikat sollte erkannt werden\n"); return 1; }
printf("PASS: addToTree - Duplikat erkannt\n");
// Test 3: treeSize
unsigned int size = treeSize(root);
if (size != 3) { printf("FAIL: treeSize sollte 3 sein, ist %u\n", size); return 1; }
printf("PASS: treeSize\n");
// Test 4: nextTreeData - Iteration (in-order: 5, 10, 15)
void *data = nextTreeData(root);
if (data == NULL || *(int*)data != 5) { printf("FAIL: Erstes Element sollte 5 sein\n"); return 1; }
data = nextTreeData(NULL);
if (data == NULL || *(int*)data != 10) { printf("FAIL: Zweites Element sollte 10 sein\n"); return 1; }
data = nextTreeData(NULL);
if (data == NULL || *(int*)data != 15) { printf("FAIL: Drittes Element sollte 15 sein\n"); return 1; }
data = nextTreeData(NULL);
if (data != NULL) { printf("FAIL: Nach dem letzten Element sollte NULL kommen\n"); return 1; }
printf("PASS: nextTreeData - Iteration\n");
// Test 5: clearTree
clearTree(root);
root = NULL;
// Nach clearTree sollte treeSize 0 sein (aber da root NULL, testen wir indirekt)
printf("PASS: clearTree (no crash)\n");
// Test 6: Leerer Baum
size = treeSize(NULL);
if (size != 0) { printf("FAIL: Leerer Baum sollte Größe 0 haben\n"); return 1; }
data = nextTreeData(NULL);
if (data != NULL) { printf("FAIL: Leerer Baum sollte NULL zurückgeben\n"); return 1; }
printf("PASS: Leerer Baum\n");
printf("ALL BINTREE TESTS PASSED\n");
return 0;
}

Binary file not shown.

BIN
timer.o

Binary file not shown.