forked from UNN/2026-rff_mp
46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
from spravochnik import *
|
|
|
|
def test_linked_list():
|
|
head = None
|
|
head = ll_insert(head, "Ivan", "111")
|
|
head = ll_insert(head, "Anna", "222")
|
|
head = ll_insert(head, "Petr", "333")
|
|
head = ll_insert(head, "Anna", "444")
|
|
print("Linked list")
|
|
print(ll_find(head, "Anna"))
|
|
print(ll_find(head, "Olga"))
|
|
print(ll_list_all(head))
|
|
head = ll_delete(head, "Ivan")
|
|
print(ll_list_all(head))
|
|
print()
|
|
|
|
def test_hash_table():
|
|
table = ht_create()
|
|
ht_insert(table, "Ivan", "111")
|
|
ht_insert(table, "Anna", "222")
|
|
ht_insert(table, "Petr", "333")
|
|
ht_insert(table, "Anna", "444")
|
|
print("Hash table")
|
|
print(ht_find(table, "Anna"))
|
|
print(ht_find(table, "Olga"))
|
|
print(ht_list_all(table))
|
|
ht_delete(table, "Ivan")
|
|
print(ht_list_all(table))
|
|
print()
|
|
|
|
def test_bst():
|
|
root = None
|
|
root = bst_insert(root, "Ivan", "111")
|
|
root = bst_insert(root, "Anna", "222")
|
|
root = bst_insert(root, "Petr", "333")
|
|
root = bst_insert(root, "Anna", "444")
|
|
print("BST")
|
|
print(bst_find(root, "Anna"))
|
|
print(bst_find(root, "Olga"))
|
|
print(bst_list_all(root))
|
|
root = bst_delete(root, "Ivan")
|
|
print(bst_list_all(root))
|
|
|
|
test_linked_list()
|
|
test_hash_table()
|
|
test_bst() |