[1] add LinkList

This commit is contained in:
4eker 2026-04-15 16:49:57 +03:00
parent 34872ab84e
commit 2b8170c6c8
2 changed files with 69 additions and 0 deletions

26
pomelovsd/LinkedList Normal file
View File

@ -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

View File

@ -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
}