Files
ADS/P2/ADS_P2_2_Hashtable/main.cpp
2025-02-21 13:17:35 +01:00

30 lines
816 B
C++
Executable File

#define CATCH_CONFIG_RUNNER
#include "catch.h"
#include <iostream>
#include "hashtable.h"
#include <cstdlib> // Für rand() und srand()
#include <ctime> // Für time()
int main() {
Catch::Session().run();
// Initialisiere den Zufallsgenerator
srand(static_cast<unsigned int>(time(0)));
int option = 1;
while (0 < option && option < 4) {
std::cout << "Wählen Sie die Sondierungsmethode : \n1 - linear\n2 - quadratisch\n3 - Doppeltes Hashing\n> ";
std::cin >> option;
HashTable H(1000, 0.6, option);
for (int i = 0; i < 200; ++i) {
int randomValue = 1000 + rand() % 501;
H.insert(randomValue);
}
std::cout << "Anzahl der Kollisionen: " << H.getCollisionCount() << std::endl;
}
system("pause");
return 0;
}