From a597b5e46f9ed44b2acc10d19bade284541f502b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=BE=D1=80=D0=B8=D1=81=D0=BE=D0=B2=20=D0=9C=D0=B0?= =?UTF-8?q?=D1=82=D0=B2=D0=B5=D0=B9?= Date: Thu, 16 Apr 2026 01:40:22 +0300 Subject: [PATCH] =?UTF-8?q?[1]=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=B8?= =?UTF-8?q?=20=D1=81=D0=B2=D1=8F=D0=B7=D0=BD=D0=BE=D0=B3=D0=BE=20=D1=81?= =?UTF-8?q?=D0=BF=D0=B8=D1=81=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BorisovMI/lab_1/docs/data/structures.py | 66 +++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 BorisovMI/lab_1/docs/data/structures.py diff --git a/BorisovMI/lab_1/docs/data/structures.py b/BorisovMI/lab_1/docs/data/structures.py new file mode 100644 index 0000000..2568a2a --- /dev/null +++ b/BorisovMI/lab_1/docs/data/structures.py @@ -0,0 +1,66 @@ +import time +import random +import csv +import os +import matplotlib.pyplot as plt +import numpy as np +import sys + +# Связный список + +def ll_insert(head, name, phone): + + new_node = {'name': name, 'phone': phone, 'next': None} + + if head is None: + return new_node + + if head['name'] == name: + head['phone'] = phone + return head + + current = head + while current['next'] is not None: + if current['next']['name'] == name: + current['next']['phone'] = phone + return head + current = current['next'] + + current['next'] = new_node + return head + +def ll_find(head, name): + + current = head + while current is not None: + if current['name'] == name: + return current['phone'] + current = current['next'] + return None + +def ll_delete(head, name): + + if head is None: + return None + + if head['name'] == name: + return head['next'] + + current = head + while current['next'] is not None: + if current['next']['name'] == name: + current['next'] = current['next']['next'] + return head + current = current['next'] + + return head + +def ll_list_all(head): + + records = [] + current = head + while current is not None: + records.append((current['name'], current['phone'])) + current = current['next'] + records.sort(key=lambda x: x[0]) + return records \ No newline at end of file