-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesting_DLL.py
More file actions
55 lines (44 loc) · 1.63 KB
/
testing_DLL.py
File metadata and controls
55 lines (44 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from myLib.datastructures.linear.DLL import DoublyLL
from myLib.datastructures.nodes.DNode import DNode
import random
if __name__ == '__main__':
node = DNode(1)
# Testing Constructors
linked_list = DoublyLL()
print(f"Intializing DLL with a nothing:")
linked_list.print()
linked_list = DoublyLL(0)
print(f"Intializing DLL with an integer:")
linked_list.print()
linked_list = DoublyLL(node)
print(f"Intializing DLL with a node:")
linked_list.print()
# Testing Inserts
print(f"Testing insert head and tail with data from 0 - 100:")
linked_list.insert_head(DNode(random.randint(0, 100)))
linked_list.insert_tail(DNode(random.randint(0, 100)))
linked_list.print()
print(f"Testing insert with specify position with node data from 0 - 100:")
linked_list.insert(DNode(random.randint(0, 100)), 2)
linked_list.print()
# Testing Sort
print(f"Testing Sort")
linked_list.sort()
linked_list.print()
# Testing Delete
print(f"Testing delete with head and tail:")
linked_list.delete_head()
linked_list.delete_tail()
linked_list.print()
print(f"Testing delete with node specified (This will delete depending if the initialized node\n",
"was not a head or tail as it might've been deleted earlier):")
linked_list.delete(node)
linked_list.print()
print(f"Testing SortedInsert:")
for i in range (5):
i = random.randint(0, 100)
linked_list.sorted_insert(DNode(i))
linked_list.print()
print(f"Testing Clear:")
linked_list.clear()
linked_list.print()