Exemple #1
0
from linked_list import Linked_list

link_list1 = Linked_list()
link_list1.append(0)
link_list1.append(1)
link_list1.append(2)
link_list1.append(3)
link_list1.append(4)
link_list1.append(5)

item = link_list1[3]

print(item)
print(link_list1)

link_list1.delete(3)
print(link_list1)

link_list1.delete(0)
print(link_list1)

link_list1.append(6)
print(link_list1)

link_list1.prepend(0)
print(link_list1)
            a_curr.next = b_curr
        if b_curr:
            b_curr.next = a_ref

        a_curr = a_ref
        b_curr = b_ref

    return a_curr


if __name__ == "__main__":
    lst1 = Linked_list()
    lst2 = Linked_list()
    lst3 = Linked_list()
    lst1.insert(1)
    lst1.append(2)
    lst1.append(3)
    lst1.append(2)
    lst1.append(1)
    lst2.insert(2)
    lst2.append(4)
    lst2.append(6)
    lst2.append(8)
    lst2.append(10)
    lst3.insert(420)
    lst3.append(69)
    print(lst1.to_string())
    print(lst1.to_string())
    merge_lists(lst1, lst2)
    print(lst1.to_string())
    # print(lst3.to_string())
from linked_list import Linked_list

linked_list_1 = Linked_list()
linked_list_2 = Linked_list()
linked_list_3 = Linked_list()
linked_list_4 = Linked_list()

elements_1 = [3, 2, 4, 35, 6, 65, 6, 4, 3, 21]
elements_2 = [6, 32, 4, 9, 6, 1, 11, 21, 1]

for i in elements_1:
    linked_list_1.append(i)

for i in elements_2:
    linked_list_2.append(i)

print(linked_list_1.union(linked_list_2))
print(linked_list_1.intersection(linked_list_2))

elements_3 = [3, 2, 4, 35, 6, 65, 6, 4, 3, 23]
elements_4 = [1, 7, 8, 9, 11, 21, 1]

for i in elements_3:
    linked_list_3.append(i)

for i in elements_4:
    linked_list_4.append(i)

print(linked_list_3.union(linked_list_4))
print(linked_list_3.intersection(linked_list_4))