2026-rff_mp/ShapovalovKA/docs/data/1Task/res.py

48 lines
1.6 KiB
Python
Raw Normal View History

2026-05-25 08:58:51 +00:00
import csv
import matplotlib.pyplot as plt
array_arr = []
array_list = []
array_hash = []
array_bin = []
with open('results.csv', 'r', encoding='utf-8-sig') as file:
reader = csv.reader(file, delimiter=';')
next(reader) # пропускаем заголовок
values = []
for row in reader:
values.append(float(row[3]))
array_arr = values[0:4]
array_list = values[4:8]
array_hash = values[8:12]
array_bin = values[12:16]
print(f"array_arr : {array_arr}")
print(f"array_list: {array_list}")
print(f"array_hash: {array_hash}")
print(f"array_bin : {array_bin}")
l = [1, 2, 3, 4]
#визуализация без дерева
plt.plot(l, array_arr, label = 'Array', c='black')
plt.plot(l, array_list, label = 'Linked list', c='blue')
plt.plot(l, array_hash, label = 'Hash table', c='orange')
plt.ylabel('array') #название по y
plt.xlabel('l') #название по x
plt.legend(loc='upper center', bbox_to_anchor=(0.5, 1.15), ncol = 3)
plt.savefig('t1p1.png', dpi=300, bbox_inches='tight') #сохранение в файле
plt.show()
#визуализация с деревом
plt.plot(l, array_arr, label = 'Array', c='black')
plt.plot(l, array_list, label = 'Linked list', c='blue')
plt.plot(l, array_hash, label = 'Hash table', c='orange')
plt.plot(l, array_bin, label = 'Binary tree', c='red')
plt.ylabel('array') #название по y
plt.xlabel('l') #название по x
plt.legend(loc='upper center', bbox_to_anchor=(0.5, 1.15), ncol = 4)
plt.savefig('t1p2.png', dpi=300, bbox_inches='tight') #сохранение в файле
plt.show()