updated lab5 and 6

This commit is contained in:
Student 2025-09-09 09:24:01 +05:30
parent 13bcfbbafd
commit fefb795f80
2 changed files with 4 additions and 4 deletions

View file

@ -7,12 +7,12 @@ def ds_gen(dsize):
"""Generate random strings dataset"""
dataset = []
for _ in range(dsize):
length = random.randint(10, 50)
length = random.randint(500000, 1000000)
random_string = ''.join(random.choices(string.ascii_letters + string.digits, k=length))
dataset.append(random_string)
return dataset
def hash_benchmark(dataset, hash_func, hash_name):
def hash_benchmark(dataset, hash_func):
"""Benchmark hashing function and detect collisions"""
start_time = time.time()
hashes = {}
@ -43,7 +43,7 @@ def main():
print(f"Testing with {len(dataset)} strings\n")
for hash_func, name in hash_functions:
time_taken, collision_count, collisions = hash_benchmark(dataset, hash_func, name)
time_taken, collision_count, collisions = hash_benchmark(dataset, hash_func)
print(f"{name}:")
print(f" Time: {time_taken:.6f} seconds")
print(f" Collisions: {collision_count}")