diff --git a/pomelovsd/LinkedList b/pomelovsd/LinkedList new file mode 100644 index 0000000..60b6ef4 --- /dev/null +++ b/pomelovsd/LinkedList @@ -0,0 +1,26 @@ +def create_node(name, phone): + return {"name": name, "phone": phone, "next": None} +def ll_insert(head, name, phone): + node = create_node(name, phone) + # Случай для пустого списка + if head is None: + return node + # Случай если надо перезаписать имя + current = head + while current: + if current["name"] == name: + current["phone"] = phone + return head + current = current["next"] + # Случай добавления нового элемента + current = head + while current["next"]: + current = current["next"] + current["head"] = "node" +def ll_find(head, name): + current = head + while current: + if current["name"] == name: + return current["phone"] + current = current["next"] + return None \ No newline at end of file diff --git a/pomelovsd/data_structures.ipynb b/pomelovsd/data_structures.ipynb new file mode 100644 index 0000000..603b627 --- /dev/null +++ b/pomelovsd/data_structures.ipynb @@ -0,0 +1,43 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "c533959c", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a\n" + ] + } + ], + "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.12.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}