diff --git a/romanovpv/task 1/bst.py b/romanovpv/task 1/bst.py new file mode 100644 index 0000000..fe639dc --- /dev/null +++ b/romanovpv/task 1/bst.py @@ -0,0 +1,15 @@ +def bst_insert(root, name, phone): + {'name': name, 'phone': phone, 'left': None, 'right': None} + pass + +def bst_find(root, name): + pass + +def bst_delete(root, name): + pass + +def bst_delete(root, name): + pass + +def bst_list_all(root): + pass \ No newline at end of file diff --git a/romanovpv/task 1/hash_table.py b/romanovpv/task 1/hash_table.py new file mode 100644 index 0000000..3618220 --- /dev/null +++ b/romanovpv/task 1/hash_table.py @@ -0,0 +1,24 @@ +import linked_list as ll + +def ht_create(size = 100): + return[None] * size + +def _hash(name, size): + return hash(name) % size + +def ht_insert(buckets, name, phone): + index = _hash(name, len(buckets)) + buckets[index] = ll.ll_insert(buckets[index], name, phone) + return buckets + +def ht_find(buckets, name): + index = hash(name, len(buckets)) + return ll.ll_find(buckets[index], name) + +def ht_delete(buckets, name): + index = _hash(name, len(buckets)) + buckets[index] = ll.ll_delete(buckets[index], name) + return buckets + +def ht_list_all(buckets): + pass \ No newline at end of file diff --git a/romanovpv/task 1/linked_list.py b/romanovpv/task 1/linked_list.py new file mode 100644 index 0000000..1bb6143 --- /dev/null +++ b/romanovpv/task 1/linked_list.py @@ -0,0 +1,12 @@ +def ll_insert(head, name, phone): + {'name': name, 'phone': phone} + pass + +def ll_find(head, name): + pass + +def ll_delete(head, name): + pass + +def ll_list_all(head): + pass \ No newline at end of file diff --git a/romanovpv/task 1/main.py b/romanovpv/task 1/main.py new file mode 100644 index 0000000..fd60290 --- /dev/null +++ b/romanovpv/task 1/main.py @@ -0,0 +1,4 @@ +import time +import linked_list as ll +import hash_table as ht +import bst \ No newline at end of file