data-structure-typed 1.19.2 → 1.19.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/dist/data-structures/binary-tree/aa-tree.js +2 -5
  2. package/dist/data-structures/binary-tree/abstract-binary-tree.js +361 -488
  3. package/dist/data-structures/binary-tree/avl-tree.js +46 -90
  4. package/dist/data-structures/binary-tree/b-tree.js +2 -5
  5. package/dist/data-structures/binary-tree/binary-indexed-tree.js +17 -22
  6. package/dist/data-structures/binary-tree/binary-tree.js +9 -31
  7. package/dist/data-structures/binary-tree/bst.js +96 -139
  8. package/dist/data-structures/binary-tree/rb-tree.js +32 -56
  9. package/dist/data-structures/binary-tree/segment-tree.js +78 -120
  10. package/dist/data-structures/binary-tree/splay-tree.js +2 -5
  11. package/dist/data-structures/binary-tree/tree-multiset.js +176 -253
  12. package/dist/data-structures/binary-tree/two-three-tree.js +2 -5
  13. package/dist/data-structures/graph/abstract-graph.js +340 -574
  14. package/dist/data-structures/graph/directed-graph.js +146 -276
  15. package/dist/data-structures/graph/undirected-graph.js +87 -176
  16. package/dist/data-structures/hash/coordinate-map.js +23 -45
  17. package/dist/data-structures/hash/coordinate-set.js +20 -42
  18. package/dist/data-structures/hash/hash-table.js +2 -5
  19. package/dist/data-structures/hash/pair.js +2 -5
  20. package/dist/data-structures/hash/tree-map.js +2 -5
  21. package/dist/data-structures/hash/tree-set.js +2 -5
  22. package/dist/data-structures/heap/heap.js +53 -77
  23. package/dist/data-structures/heap/max-heap.js +8 -26
  24. package/dist/data-structures/heap/min-heap.js +8 -26
  25. package/dist/data-structures/linked-list/doubly-linked-list.js +132 -197
  26. package/dist/data-structures/linked-list/singly-linked-list.js +112 -173
  27. package/dist/data-structures/linked-list/skip-linked-list.js +2 -5
  28. package/dist/data-structures/matrix/matrix.js +7 -8
  29. package/dist/data-structures/matrix/matrix2d.js +76 -93
  30. package/dist/data-structures/matrix/navigator.js +18 -37
  31. package/dist/data-structures/matrix/vector2d.js +80 -101
  32. package/dist/data-structures/priority-queue/max-priority-queue.js +11 -39
  33. package/dist/data-structures/priority-queue/min-priority-queue.js +11 -39
  34. package/dist/data-structures/priority-queue/priority-queue.js +93 -139
  35. package/dist/data-structures/queue/deque.js +82 -128
  36. package/dist/data-structures/queue/queue.js +24 -25
  37. package/dist/data-structures/stack/stack.js +21 -22
  38. package/dist/data-structures/tree/tree.js +32 -45
  39. package/dist/data-structures/trie/trie.js +93 -200
  40. package/dist/utils/utils.js +22 -107
  41. package/dist/utils/validate-type.js +2 -2
  42. package/package.json +1 -1
  43. package/src/assets/complexities-diff.jpg +0 -0
  44. package/src/assets/data-structure-complexities.jpg +0 -0
  45. package/src/assets/logo.png +0 -0
  46. package/src/assets/overview-diagram-of-data-structures.png +0 -0
  47. package/src/data-structures/binary-tree/aa-tree.ts +3 -0
  48. package/src/data-structures/binary-tree/abstract-binary-tree.ts +1528 -0
  49. package/src/data-structures/binary-tree/avl-tree.ts +297 -0
  50. package/src/data-structures/binary-tree/b-tree.ts +3 -0
  51. package/src/data-structures/binary-tree/binary-indexed-tree.ts +78 -0
  52. package/src/data-structures/binary-tree/binary-tree.ts +40 -0
  53. package/src/data-structures/binary-tree/bst.ts +435 -0
  54. package/src/data-structures/binary-tree/diagrams/avl-tree-inserting.gif +0 -0
  55. package/src/data-structures/binary-tree/diagrams/bst-rotation.gif +0 -0
  56. package/src/data-structures/binary-tree/diagrams/segment-tree.png +0 -0
  57. package/src/data-structures/binary-tree/index.ts +12 -0
  58. package/src/data-structures/binary-tree/rb-tree.ts +102 -0
  59. package/src/data-structures/binary-tree/segment-tree.ts +243 -0
  60. package/src/data-structures/binary-tree/splay-tree.ts +3 -0
  61. package/src/data-structures/binary-tree/tree-multiset.ts +694 -0
  62. package/src/data-structures/binary-tree/two-three-tree.ts +3 -0
  63. package/src/data-structures/diagrams/README.md +5 -0
  64. package/src/data-structures/graph/abstract-graph.ts +1032 -0
  65. package/src/data-structures/graph/diagrams/adjacency-list-pros-cons.jpg +0 -0
  66. package/src/data-structures/graph/diagrams/adjacency-list.jpg +0 -0
  67. package/src/data-structures/graph/diagrams/adjacency-matrix-pros-cons.jpg +0 -0
  68. package/src/data-structures/graph/diagrams/adjacency-matrix.jpg +0 -0
  69. package/src/data-structures/graph/diagrams/dfs-can-do.jpg +0 -0
  70. package/src/data-structures/graph/diagrams/edge-list-pros-cons.jpg +0 -0
  71. package/src/data-structures/graph/diagrams/edge-list.jpg +0 -0
  72. package/src/data-structures/graph/diagrams/max-flow.jpg +0 -0
  73. package/src/data-structures/graph/diagrams/mst.jpg +0 -0
  74. package/src/data-structures/graph/diagrams/tarjan-articulation-point-bridge.png +0 -0
  75. package/src/data-structures/graph/diagrams/tarjan-complicate-simple.png +0 -0
  76. package/src/data-structures/graph/diagrams/tarjan-strongly-connected-component.png +0 -0
  77. package/src/data-structures/graph/diagrams/tarjan.mp4 +0 -0
  78. package/src/data-structures/graph/diagrams/tarjan.webp +0 -0
  79. package/src/data-structures/graph/directed-graph.ts +472 -0
  80. package/src/data-structures/graph/index.ts +3 -0
  81. package/src/data-structures/graph/undirected-graph.ts +270 -0
  82. package/src/data-structures/hash/coordinate-map.ts +67 -0
  83. package/src/data-structures/hash/coordinate-set.ts +56 -0
  84. package/src/data-structures/hash/hash-table.ts +3 -0
  85. package/src/data-structures/hash/index.ts +6 -0
  86. package/src/data-structures/hash/pair.ts +3 -0
  87. package/src/data-structures/hash/tree-map.ts +3 -0
  88. package/src/data-structures/hash/tree-set.ts +3 -0
  89. package/src/data-structures/heap/heap.ts +183 -0
  90. package/src/data-structures/heap/index.ts +3 -0
  91. package/src/data-structures/heap/max-heap.ts +31 -0
  92. package/src/data-structures/heap/min-heap.ts +34 -0
  93. package/src/data-structures/index.ts +15 -0
  94. package/src/data-structures/interfaces/abstract-binary-tree.ts +231 -0
  95. package/src/data-structures/interfaces/abstract-graph.ts +40 -0
  96. package/src/data-structures/interfaces/avl-tree.ts +28 -0
  97. package/src/data-structures/interfaces/binary-tree.ts +8 -0
  98. package/src/data-structures/interfaces/bst.ts +32 -0
  99. package/src/data-structures/interfaces/directed-graph.ts +20 -0
  100. package/src/data-structures/interfaces/doubly-linked-list.ts +1 -0
  101. package/src/data-structures/interfaces/heap.ts +1 -0
  102. package/src/data-structures/interfaces/index.ts +15 -0
  103. package/src/data-structures/interfaces/navigator.ts +1 -0
  104. package/src/data-structures/interfaces/priority-queue.ts +1 -0
  105. package/src/data-structures/interfaces/rb-tree.ts +11 -0
  106. package/src/data-structures/interfaces/segment-tree.ts +1 -0
  107. package/src/data-structures/interfaces/singly-linked-list.ts +1 -0
  108. package/src/data-structures/interfaces/tree-multiset.ts +12 -0
  109. package/src/data-structures/interfaces/undirected-graph.ts +6 -0
  110. package/src/data-structures/linked-list/doubly-linked-list.ts +573 -0
  111. package/src/data-structures/linked-list/index.ts +3 -0
  112. package/src/data-structures/linked-list/singly-linked-list.ts +490 -0
  113. package/src/data-structures/linked-list/skip-linked-list.ts +3 -0
  114. package/src/data-structures/matrix/index.ts +4 -0
  115. package/src/data-structures/matrix/matrix.ts +27 -0
  116. package/src/data-structures/matrix/matrix2d.ts +208 -0
  117. package/src/data-structures/matrix/navigator.ts +122 -0
  118. package/src/data-structures/matrix/vector2d.ts +316 -0
  119. package/src/data-structures/priority-queue/index.ts +3 -0
  120. package/src/data-structures/priority-queue/max-priority-queue.ts +49 -0
  121. package/src/data-structures/priority-queue/min-priority-queue.ts +50 -0
  122. package/src/data-structures/priority-queue/priority-queue.ts +354 -0
  123. package/src/data-structures/queue/deque.ts +251 -0
  124. package/src/data-structures/queue/index.ts +2 -0
  125. package/src/data-structures/queue/queue.ts +120 -0
  126. package/src/data-structures/stack/index.ts +1 -0
  127. package/src/data-structures/stack/stack.ts +98 -0
  128. package/src/data-structures/tree/index.ts +1 -0
  129. package/src/data-structures/tree/tree.ts +69 -0
  130. package/src/data-structures/trie/index.ts +1 -0
  131. package/src/data-structures/trie/trie.ts +227 -0
  132. package/src/data-structures/types/abstract-binary-tree.ts +42 -0
  133. package/src/data-structures/types/abstract-graph.ts +5 -0
  134. package/src/data-structures/types/avl-tree.ts +5 -0
  135. package/src/data-structures/types/binary-tree.ts +9 -0
  136. package/src/data-structures/types/bst.ts +12 -0
  137. package/src/data-structures/types/directed-graph.ts +8 -0
  138. package/src/data-structures/types/doubly-linked-list.ts +1 -0
  139. package/src/data-structures/types/heap.ts +5 -0
  140. package/src/data-structures/types/helpers.ts +1 -0
  141. package/src/data-structures/types/index.ts +15 -0
  142. package/src/data-structures/types/navigator.ts +13 -0
  143. package/src/data-structures/types/priority-queue.ts +9 -0
  144. package/src/data-structures/types/rb-tree.ts +8 -0
  145. package/src/data-structures/types/segment-tree.ts +1 -0
  146. package/src/data-structures/types/singly-linked-list.ts +1 -0
  147. package/src/data-structures/types/tree-multiset.ts +8 -0
  148. package/src/index.ts +2 -0
  149. package/src/utils/index.ts +3 -0
  150. package/src/utils/types/index.ts +2 -0
  151. package/src/utils/types/utils.ts +6 -0
  152. package/src/utils/types/validate-type.ts +25 -0
  153. package/src/utils/utils.ts +78 -0
  154. package/src/utils/validate-type.ts +69 -0
  155. package/tsconfig.json +1 -1
@@ -0,0 +1,15 @@
1
+ export * from './hash';
2
+ export * from './linked-list';
3
+ export * from './stack';
4
+ export * from './queue';
5
+ export * from './graph';
6
+ export * from './binary-tree';
7
+ export * from './tree';
8
+ export * from './heap';
9
+ export * from './priority-queue';
10
+ export * from './matrix';
11
+ export * from './trie';
12
+ export * from './interfaces';
13
+ export * from './types';
14
+
15
+
@@ -0,0 +1,231 @@
1
+ import {
2
+ AbstractBinaryTreeNodeProperties,
3
+ AbstractBinaryTreeNodeProperty,
4
+ BinaryTreeDeletedResult,
5
+ BinaryTreeNodeId,
6
+ BinaryTreeNodePropertyName,
7
+ DFSOrderPattern,
8
+ FamilyPosition,
9
+ LoopType,
10
+ NodeOrPropertyName
11
+ } from '../types';
12
+ import {AbstractBinaryTreeNode} from '../binary-tree';
13
+
14
+ export interface IAbstractBinaryTreeNode<T, NEIGHBOR extends IAbstractBinaryTreeNode<T, NEIGHBOR>> {
15
+
16
+ get id(): BinaryTreeNodeId
17
+
18
+ set id(v: BinaryTreeNodeId)
19
+
20
+ get val(): T | undefined
21
+
22
+ set val(v: T | undefined)
23
+
24
+ get left(): NEIGHBOR | null | undefined
25
+
26
+ set left(v: NEIGHBOR | null | undefined)
27
+
28
+ get right(): NEIGHBOR | null | undefined
29
+
30
+ set right(v: NEIGHBOR | null | undefined)
31
+
32
+ get parent(): NEIGHBOR | null | undefined
33
+
34
+ set parent(v: NEIGHBOR | null | undefined)
35
+
36
+ get familyPosition(): FamilyPosition
37
+
38
+ get height(): number
39
+
40
+ set height(v: number)
41
+ }
42
+
43
+ export interface IAbstractBinaryTree<N extends AbstractBinaryTreeNode<N['val'], N>> {
44
+ createNode(id: BinaryTreeNodeId, val?: N['val'], count?: number): N | null
45
+
46
+ get loopType(): LoopType
47
+
48
+ get visitedId(): BinaryTreeNodeId[]
49
+
50
+ get visitedVal(): Array<N['val']>
51
+
52
+ get visitedNode(): N[]
53
+
54
+ get visitedCount(): number[]
55
+
56
+ get visitedLeftSum(): number[]
57
+
58
+ get autoIncrementId(): boolean
59
+
60
+ get maxId(): number
61
+
62
+ get isMergeDuplicatedVal(): boolean
63
+
64
+ get root(): N | null
65
+
66
+ get size(): number
67
+
68
+ swapLocation(srcNode: N, destNode: N): N
69
+
70
+ clear(): void
71
+
72
+ isEmpty(): boolean
73
+
74
+ add(id: BinaryTreeNodeId, val?: N['val'], count?: number): N | null | undefined
75
+
76
+ addTo(newNode: N | null, parent: N): N | null | undefined
77
+
78
+ addMany(data: N[] | Array<N['val']>): (N | null | undefined)[]
79
+
80
+ fill(data: N[] | Array<N['val']>): boolean
81
+
82
+ remove(id: BinaryTreeNodeId, ignoreCount?: boolean): BinaryTreeDeletedResult<N>[]
83
+
84
+ getDepth(node: N): number
85
+
86
+ getHeight(beginRoot?: N | null): number
87
+
88
+ getMinHeight(beginRoot?: N | null): number
89
+
90
+ isPerfectlyBalanced(beginRoot?: N | null): boolean
91
+
92
+ getNodes(nodeProperty: BinaryTreeNodeId | N, propertyName ?: BinaryTreeNodePropertyName, onlyOne ?: boolean): N[]
93
+
94
+ has(nodeProperty: BinaryTreeNodeId | N, propertyName ?: BinaryTreeNodePropertyName): boolean
95
+
96
+ get(nodeProperty: BinaryTreeNodeId | N, propertyName ?: BinaryTreeNodePropertyName): N | null
97
+
98
+ getPathToRoot(node: N): N[]
99
+
100
+ getLeftMost(): N | null;
101
+
102
+ getLeftMost(node: N): N;
103
+
104
+ getLeftMost(node?: N | null): N | null
105
+
106
+ getRightMost(): N | null;
107
+
108
+ getRightMost(node: N): N;
109
+
110
+ getRightMost(node?: N | null): N | null
111
+
112
+ isBSTByRooted(node: N | null): boolean
113
+
114
+ isBST(node?: N | null): boolean
115
+
116
+ getSubTreeSize(subTreeRoot: N | null | undefined): number
117
+
118
+ // --- start additional methods ---
119
+
120
+ subTreeSum(subTreeRoot: N, propertyName ?: BinaryTreeNodePropertyName): number
121
+
122
+ subTreeAdd(subTreeRoot: N, delta: number, propertyName ?: BinaryTreeNodePropertyName): boolean
123
+
124
+ BFS(): BinaryTreeNodeId[];
125
+
126
+ BFS(nodeOrPropertyName: 'id'): BinaryTreeNodeId[];
127
+
128
+ BFS(nodeOrPropertyName: 'val'): N['val'][];
129
+
130
+ BFS(nodeOrPropertyName: 'node'): N[];
131
+
132
+ BFS(nodeOrPropertyName: 'count'): number[];
133
+
134
+ BFS(nodeOrPropertyName ?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>
135
+
136
+ DFS(): BinaryTreeNodeId[];
137
+
138
+ DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
139
+
140
+ DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'val'): N[];
141
+
142
+ DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'node'): N[];
143
+
144
+ DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'count'): number[];
145
+
146
+ DFS(pattern ?: 'in' | 'pre' | 'post', nodeOrPropertyName ?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>
147
+
148
+ DFSIterative(): BinaryTreeNodeId[];
149
+
150
+ DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
151
+
152
+ DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'val'): N[];
153
+
154
+ DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'node'): N[];
155
+
156
+ DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'count'): number[];
157
+
158
+ DFSIterative(pattern ?: 'in' | 'pre' | 'post', nodeOrPropertyName ?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>
159
+
160
+ levelIterative(node: N | null): BinaryTreeNodeId[];
161
+
162
+ levelIterative(node: N | null, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
163
+
164
+ levelIterative(node: N | null, nodeOrPropertyName?: 'val'): N['val'][];
165
+
166
+ levelIterative(node: N | null, nodeOrPropertyName?: 'node'): N[];
167
+
168
+ levelIterative(node: N | null, nodeOrPropertyName?: 'count'): number[];
169
+
170
+ levelIterative(node: N | null, nodeOrPropertyName ?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>
171
+
172
+ listLevels(node: N | null): BinaryTreeNodeId[][];
173
+
174
+ listLevels(node: N | null, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[][];
175
+
176
+ listLevels(node: N | null, nodeOrPropertyName?: 'val'): N['val'][][];
177
+
178
+ listLevels(node: N | null, nodeOrPropertyName?: 'node'): N[][];
179
+
180
+ listLevels(node: N | null, nodeOrPropertyName?: 'count'): number[][];
181
+
182
+ listLevels(node: N | null, nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperty<N>[][]
183
+
184
+ getPredecessor(node: N): N
185
+
186
+ morris(): BinaryTreeNodeId[];
187
+
188
+ morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
189
+
190
+ morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'val'): N[];
191
+
192
+ morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'node'): N[];
193
+
194
+ morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'count'): number[];
195
+
196
+ morris(pattern?: 'in' | 'pre' | 'post', nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>
197
+
198
+ // _setLoopType(value: LoopType): void
199
+ //
200
+ // _setVisitedId(value: BinaryTreeNodeId[]): void
201
+ //
202
+ // _setVisitedVal(value: Array<N>): void
203
+ //
204
+ // _setVisitedNode(value: N[]): void
205
+ //
206
+ // setVisitedCount(value: number[]): void
207
+ //
208
+ // _setVisitedLeftSum(value: number[]): void
209
+ //
210
+ // _setAutoIncrementId(value: boolean): void
211
+ //
212
+ // _setMaxId(value: number): void
213
+ //
214
+ // _setIsDuplicatedVal(value: boolean): void
215
+ //
216
+ // _setRoot(v: N | null): void
217
+ //
218
+ // _setSize(v: number): void
219
+ //
220
+ // _setCount(v: number): void
221
+ //
222
+ // _resetResults(): void
223
+
224
+ // _pushByPropertyNameStopOrNot(cur: N, result: (N | null | undefined)[], nodeProperty: BinaryTreeNodeId | N, propertyName ?: BinaryTreeNodePropertyName, onlyOne ?: boolean): void
225
+ //
226
+ // _accumulatedByPropertyName(node: N, nodeOrPropertyName ?: NodeOrPropertyName): void
227
+ //
228
+ // _getResultByPropertyName(nodeOrPropertyName ?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>
229
+
230
+ // --- end additional methods ---
231
+ }
@@ -0,0 +1,40 @@
1
+ import {VertexId} from '../types';
2
+
3
+ export interface IAbstractGraph<V, E> {
4
+
5
+ hasVertex(vertexOrId: V | VertexId): boolean;
6
+
7
+ // _getVertex(vertexOrId: VertexId | V): V | null;
8
+
9
+ // _getVertexId(vertexOrId: V | VertexId): VertexId;
10
+
11
+ addVertex(id: VertexId, val?: V): boolean;
12
+
13
+ // _addVertexOnly(newVertex: V): boolean;
14
+
15
+ removeVertex(vertexOrId: V | VertexId): boolean;
16
+
17
+ removeAllVertices(vertices: V[] | VertexId[]): boolean;
18
+
19
+ degreeOf(vertexOrId: V | VertexId): number;
20
+
21
+ edgesOf(vertexOrId: V | VertexId): E[];
22
+
23
+ hasEdge(src: V | VertexId, dest: V | VertexId): boolean;
24
+
25
+ getEdge(srcOrId: V | VertexId, destOrId: V | VertexId): E | null;
26
+
27
+ edgeSet(): E[];
28
+
29
+ addEdge(src: V | VertexId, dest: V | VertexId, weight: number, val: E): boolean;
30
+
31
+ // _addEdgeOnly(edge: E): boolean;
32
+
33
+ removeEdge(edge: E): E | null;
34
+
35
+ setEdgeWeight(srcOrId: V | VertexId, destOrId: V | VertexId, weight: number): boolean;
36
+
37
+ getMinPathBetween(v1: V | VertexId, v2: V | VertexId, isWeight?: boolean): V[] | null;
38
+
39
+ getNeighbors(vertexOrId: V | VertexId): V[];
40
+ }
@@ -0,0 +1,28 @@
1
+ import {AVLTreeNode} from '../binary-tree';
2
+ import {IBST, IBSTNode} from './bst';
3
+ import {BinaryTreeDeletedResult, BinaryTreeNodeId} from '../types';
4
+
5
+ export interface IAVLTreeNode<T, NEIGHBOR extends IAVLTreeNode<T, NEIGHBOR>> extends IBSTNode<T, NEIGHBOR> {
6
+
7
+ }
8
+
9
+ export interface IAVLTree<N extends AVLTreeNode<N['val'], N>> extends IBST<N> {
10
+
11
+ add(id: BinaryTreeNodeId, val?: N['val'] | null): N | null | undefined
12
+
13
+ remove(id: BinaryTreeNodeId, isUpdateAllLeftSum?: boolean): BinaryTreeDeletedResult<N>[]
14
+
15
+ balanceFactor(node: N): number
16
+
17
+ updateHeight(node: N): void
18
+
19
+ balancePath(node: N): void
20
+
21
+ balanceLL(A: N): void
22
+
23
+ balanceLR(A: N): void
24
+
25
+ balanceRR(A: N): void
26
+
27
+ balanceRL(A: N): void
28
+ }
@@ -0,0 +1,8 @@
1
+ import {BinaryTreeNode} from '../binary-tree';
2
+ import {IAbstractBinaryTree, IAbstractBinaryTreeNode} from './abstract-binary-tree';
3
+
4
+ export interface IBinaryTreeNode<T, NEIGHBOR extends IBinaryTreeNode<T, NEIGHBOR>> extends IAbstractBinaryTreeNode<T, NEIGHBOR> {
5
+ }
6
+
7
+ export interface IBinaryTree<N extends BinaryTreeNode<N['val'], N>> extends IAbstractBinaryTree<N> {
8
+ }
@@ -0,0 +1,32 @@
1
+ import {BSTNode} from '../binary-tree';
2
+ import {IBinaryTree, IBinaryTreeNode} from './binary-tree';
3
+ import {BinaryTreeDeletedResult, BinaryTreeNodeId, BinaryTreeNodePropertyName} from '../types';
4
+
5
+ export interface IBSTNode<T, NEIGHBOR extends IBSTNode<T, NEIGHBOR>> extends IBinaryTreeNode<T, NEIGHBOR> {
6
+ }
7
+
8
+ export interface IBST<N extends BSTNode<N['val'], N>> extends IBinaryTree<N> {
9
+ createNode(id: BinaryTreeNodeId, val?: N['val'], count?: number): N
10
+
11
+ add(id: BinaryTreeNodeId, val?: N['val'] | null, count?: number): N | null | undefined
12
+
13
+ get(nodeProperty: BinaryTreeNodeId | N, propertyName ?: BinaryTreeNodePropertyName): N | null
14
+
15
+ lastKey(): BinaryTreeNodeId
16
+
17
+ remove(id: BinaryTreeNodeId, ignoreCount?: boolean): BinaryTreeDeletedResult<N>[]
18
+
19
+ getNodes(nodeProperty: BinaryTreeNodeId | N, propertyName ?: BinaryTreeNodePropertyName, onlyOne ?: boolean): N[]
20
+
21
+ // --- start additional functions
22
+
23
+ lesserSum(id: BinaryTreeNodeId, propertyName ?: BinaryTreeNodePropertyName): number
24
+
25
+ allGreaterNodesAdd(node: N, delta: number, propertyName ?: BinaryTreeNodePropertyName): boolean
26
+
27
+ perfectlyBalance(): boolean
28
+
29
+ isAVLBalanced(): boolean
30
+
31
+ // --- end additional functions
32
+ }
@@ -0,0 +1,20 @@
1
+ import {VertexId} from '../types';
2
+ import {IAbstractGraph} from './abstract-graph';
3
+
4
+ export interface IDirectedGraph<V, E> extends IAbstractGraph<V, E> {
5
+ incomingEdgesOf(vertex: V): E[];
6
+
7
+ outgoingEdgesOf(vertex: V): E[];
8
+
9
+ inDegreeOf(vertexOrId: V | VertexId): number;
10
+
11
+ outDegreeOf(vertexOrId: V | VertexId): number;
12
+
13
+ getEdgeSrc(e: E): V | null;
14
+
15
+ getEdgeDest(e: E): V | null;
16
+
17
+ removeEdgeSrcToDest(srcOrId: V | VertexId, destOrId: V | VertexId): E | null;
18
+
19
+ removeEdgesBetween(v1: V | VertexId, v2: V | VertexId): E[];
20
+ }
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1,15 @@
1
+ export * from './abstract-binary-tree';
2
+ export * from './abstract-graph';
3
+ export * from './avl-tree';
4
+ export * from './binary-tree';
5
+ export * from './bst';
6
+ export * from './directed-graph';
7
+ export * from './doubly-linked-list';
8
+ export * from './heap';
9
+ export * from './navigator';
10
+ export * from './priority-queue';
11
+ export * from './rb-tree';
12
+ export * from './segment-tree';
13
+ export * from './singly-linked-list';
14
+ export * from './tree-multiset';
15
+ export * from './undirected-graph';
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1,11 @@
1
+ import {RBTreeNode} from '../binary-tree';
2
+ import {IBST, IBSTNode} from './bst';
3
+ import {BinaryTreeNodeId} from '../types';
4
+
5
+ export interface IRBTreeNode<T, NEIGHBOR extends IRBTreeNode<T, NEIGHBOR>> extends IBSTNode<T, NEIGHBOR> {
6
+ }
7
+
8
+ export interface IRBTree<N extends RBTreeNode<N['val'], N>> extends IBST<N> {
9
+
10
+ createNode(id: BinaryTreeNodeId, val?: N['val'], count?: number): N
11
+ }
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1,12 @@
1
+ import {TreeMultisetNode} from '../binary-tree';
2
+ import {IBSTNode} from './bst';
3
+ import {IAVLTree} from './avl-tree';
4
+
5
+ export interface ITreeMultisetNode<T, NEIGHBOR extends ITreeMultisetNode<T, NEIGHBOR>> extends IBSTNode<T, NEIGHBOR> {
6
+
7
+ }
8
+
9
+ export interface ITreeMultiset<N extends TreeMultisetNode<N['val'], N>> extends IAVLTree<N> {
10
+
11
+
12
+ }
@@ -0,0 +1,6 @@
1
+ import {VertexId} from '../types';
2
+ import {IAbstractGraph} from './abstract-graph';
3
+
4
+ export interface IUNDirectedGraph<V, E> extends IAbstractGraph<V, E> {
5
+ removeEdgeBetween(v1: V | VertexId, v2: V | VertexId): E | null;
6
+ }