2026-rff_mp/MusinAA/docs/Report 1.ipynb
2026-03-30 17:47:24 +03:00

127 lines
3.3 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"id": "2acfa743",
"metadata": {},
"source": [
"# 0. Подготовим окружение"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "4689b73e",
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"import os\n",
"sys.path.insert(0, os.path.abspath( '../task1'))\n",
"sys.path.insert(0, os.path.abspath( '../'))"
]
},
{
"cell_type": "markdown",
"id": "37cc11a5",
"metadata": {},
"source": [
"# 1. Генерация тестовых данных\n",
"\n",
"Создадим список records из N=10000 элементов. Каждый элемент — кортеж (name, phone). \n",
"Имена возъмём случайные из небольшого набора (чтобы были повторения и коллизии). \n",
"Для проверки влияния порядка подготовим два варианта: \n",
"\n",
"_records_shuffled_ — случайный порядок. \n",
"_records_sorted_ — отсортированный по имени (по алфавиту)."
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "7d073d06",
"metadata": {},
"outputs": [],
"source": [
"from util.randomNames import generate_test_data\n",
"records_shuffled = generate_test_data(N=10000)\n",
"records_sorted = generate_test_data(N=10000, _sorted=True)\n",
"\n",
"from util.timeTester import insert_tester"
]
},
{
"cell_type": "markdown",
"id": "c2f4989c",
"metadata": {},
"source": [
"# 2. Проведение замеров\n",
"### A. Время вставки"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "eba5888c",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'Function': 'll_insert', 'shuffled': 4.4217493799999374, 'sorted': 5.294112365000046}\n",
"{'Function': 'ht_insert', 'shuffled': 0.338659952999933, 'sorted': 0.20052070199994887}\n",
"{'Function': 'bst_insert', 'shuffled': 0.01834327899996424, 'sorted': 0.18432242999983828}\n"
]
}
],
"source": [
"from structures.LinkedList import *\n",
"from structures.HashTable import *\n",
"from structures.BinaryTree import *\n",
"\n",
"print(insert_tester(ll_insert, records_shuffled, records_sorted))\n",
"print(insert_tester(ht_insert, records_shuffled, records_sorted))\n",
"print(insert_tester(bst_insert, records_shuffled, records_sorted))"
]
},
{
"cell_type": "markdown",
"id": "383c4b1b",
"metadata": {},
"source": [
"### Б. Поиск 100 случайных записей и 10 несуществующих"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d1acfa50",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.2"
}
},
"nbformat": 4,
"nbformat_minor": 5
}