-
Notifications
You must be signed in to change notification settings - Fork 0
/
Time Complexity ~AVL Tree
91 lines (63 loc) · 1.73 KB
/
Time Complexity ~AVL Tree
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
## Essential ADT
### Singly Linked List ADT
#### by Array
|---|Best|Average|Worst|
|---|---|---|---|
|Build|O(n)|**O(n^2)**|O(n^2)|
|Insert|O(1)|**O(n)**|O(n)|
|Find|O(1)|**O(n)**|O(n)|
|Delete|O(1)|**O(n)**|O(n)|
#### by Struct Node
|---|Best|Average|Worst|
|---|---|---|---|
|Build|O(n)|**O(n^2)**|O(n^2)|
|Insert|O(1) (front)|**O(n)**|O(n) (back)|
|Find|O(1) (front)|**O(n)**|O(n) (back)|
|Delete|O(1) (front)|**O(n)**|O(n) (back)|
### Stack ADT
#### by Array
|---|Best|Average|Worst|
|---|---|---|---|
|Build|O(n)|**O(n)**|O(n)|
|Insert(Push)|O(1)|**O(1)**|O(n) (resize)|
|Find(Top)|O(1)|**O(1)**|O(1)|
|Delete(Pop)|O(1)|**O(1)**|O(1)|
#### by Linked List
|---|Best|Average|Worst|
|---|---|---|---|
|Build|O(n)|**O(n)**|O(n)|
|Insert(Push)|O(1)|**O(1)**|O(1)|
|Find(Top)|O(1)|**O(1)**|O(1)|
|Delete(Pop)|O(1)|**O(1)**|O(1)|
### Queue ADT
#### by Array
|---|Best|Average|Worst|
|---|---|---|---|
|Build|O(n)|**O(n)**|O(n)|
|Insert(Enqueue)|O(1)|**O(1)**|O(n) (resize)|
|Find(Peek)|O(1)|**O(1)**|O(1)|
|Delete(Dequeue)|O(1)|**O(1)**|O(1)|
#### by Linked List
|---|Best|Average|Worst|
|---|---|---|---|
|Build|O(n)|**O(n)**|O(n)|
|Insert(Enqueue)|O(1)|**O(1)**|O(1)|
|Find(Peek)|O(1)|**O(1)**|O(1)|
|Delete(Dequeue)|O(1)|**O(1)**|O(1)|
## Graph
### Binary Search Tree (BST)
#### by Struct Node
|BST's status|Best|Average|Worst|
|---|---|---|---|
|Build|O(n)|**O(n)**|O(n)|
|Insert|O(logn)|**O(logn)**|O(n)|
|Find|O(logn)|**O(logn)**|O(n)|
|Delete|O(logn)|**O(logn)**|O(n)|
### Adelson-Velskii and Landis (AVL) Tree
#### by Struct Node
|AVL Tree's status|Best|Average|Worst|
|---|---|---|---|
|Build|O(nlogn)??|**O(nlogn)??**|O(nlogn)??|
|Insert|O(logn)|**O(logn)**|O(logn)|
|Find|O(logn)|**O(logn)**|O(logn)|
|Delete|O(logn)|**O(logn)**|O(logn)|