binary-tree-typed 2.4.4 → 2.5.0
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.
- package/README.md +0 -84
- package/dist/cjs/index.cjs +965 -420
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +962 -417
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +965 -421
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +962 -418
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/common/error.d.ts +23 -0
- package/dist/types/common/index.d.ts +1 -0
- package/dist/types/data-structures/base/iterable-element-base.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +128 -51
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +210 -164
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +439 -78
- package/dist/types/data-structures/binary-tree/bst.d.ts +311 -28
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +217 -31
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +218 -152
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +1281 -5
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1087 -201
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +858 -65
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +1133 -5
- package/dist/types/data-structures/graph/abstract-graph.d.ts +44 -0
- package/dist/types/data-structures/graph/directed-graph.d.ts +220 -47
- package/dist/types/data-structures/graph/map-graph.d.ts +59 -1
- package/dist/types/data-structures/graph/undirected-graph.d.ts +218 -59
- package/dist/types/data-structures/hash/hash-map.d.ts +230 -77
- package/dist/types/data-structures/heap/heap.d.ts +287 -99
- package/dist/types/data-structures/heap/max-heap.d.ts +46 -0
- package/dist/types/data-structures/heap/min-heap.d.ts +59 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +286 -44
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +278 -65
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +415 -12
- package/dist/types/data-structures/matrix/matrix.d.ts +331 -0
- package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +57 -0
- package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +60 -0
- package/dist/types/data-structures/priority-queue/priority-queue.d.ts +60 -0
- package/dist/types/data-structures/queue/deque.d.ts +313 -66
- package/dist/types/data-structures/queue/queue.d.ts +211 -42
- package/dist/types/data-structures/stack/stack.d.ts +174 -32
- package/dist/types/data-structures/trie/trie.d.ts +213 -43
- package/dist/types/types/data-structures/binary-tree/segment-tree.d.ts +1 -1
- package/dist/types/types/data-structures/linked-list/skip-linked-list.d.ts +1 -4
- package/dist/types/types/data-structures/queue/deque.d.ts +6 -0
- package/dist/umd/binary-tree-typed.js +959 -414
- package/dist/umd/binary-tree-typed.js.map +1 -1
- package/dist/umd/binary-tree-typed.min.js +3 -3
- package/dist/umd/binary-tree-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/common/error.ts +60 -0
- package/src/common/index.ts +2 -0
- package/src/data-structures/base/iterable-element-base.ts +2 -2
- package/src/data-structures/binary-tree/avl-tree.ts +134 -51
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +303 -247
- package/src/data-structures/binary-tree/binary-tree.ts +542 -121
- package/src/data-structures/binary-tree/bst.ts +346 -37
- package/src/data-structures/binary-tree/red-black-tree.ts +309 -96
- package/src/data-structures/binary-tree/segment-tree.ts +372 -248
- package/src/data-structures/binary-tree/tree-map.ts +1292 -13
- package/src/data-structures/binary-tree/tree-multi-map.ts +1098 -215
- package/src/data-structures/binary-tree/tree-multi-set.ts +863 -69
- package/src/data-structures/binary-tree/tree-set.ts +1143 -15
- package/src/data-structures/graph/abstract-graph.ts +106 -1
- package/src/data-structures/graph/directed-graph.ts +223 -47
- package/src/data-structures/graph/map-graph.ts +59 -1
- package/src/data-structures/graph/undirected-graph.ts +299 -59
- package/src/data-structures/hash/hash-map.ts +243 -79
- package/src/data-structures/heap/heap.ts +291 -102
- package/src/data-structures/heap/max-heap.ts +48 -3
- package/src/data-structures/heap/min-heap.ts +59 -0
- package/src/data-structures/linked-list/doubly-linked-list.ts +286 -44
- package/src/data-structures/linked-list/singly-linked-list.ts +278 -65
- package/src/data-structures/linked-list/skip-linked-list.ts +689 -90
- package/src/data-structures/matrix/matrix.ts +425 -22
- package/src/data-structures/priority-queue/max-priority-queue.ts +59 -3
- package/src/data-structures/priority-queue/min-priority-queue.ts +60 -0
- package/src/data-structures/priority-queue/priority-queue.ts +60 -0
- package/src/data-structures/queue/deque.ts +343 -68
- package/src/data-structures/queue/queue.ts +211 -42
- package/src/data-structures/stack/stack.ts +174 -32
- package/src/data-structures/trie/trie.ts +215 -44
- package/src/types/data-structures/binary-tree/segment-tree.ts +1 -1
- package/src/types/data-structures/linked-list/skip-linked-list.ts +2 -1
- package/src/types/data-structures/queue/deque.ts +7 -0
- package/src/utils/utils.ts +4 -2
package/README.md
CHANGED
|
@@ -34,90 +34,6 @@ yarn add binary-tree-typed
|
|
|
34
34
|
|
|
35
35
|
[//]: # (No deletion!!! Start of Example Replace Section)
|
|
36
36
|
|
|
37
|
-
### basic BinaryTree creation and insertion
|
|
38
|
-
```typescript
|
|
39
|
-
// Create a BinaryTree with entries
|
|
40
|
-
const entries: [number, string][] = [
|
|
41
|
-
[6, 'six'],
|
|
42
|
-
[1, 'one'],
|
|
43
|
-
[2, 'two'],
|
|
44
|
-
[7, 'seven'],
|
|
45
|
-
[5, 'five'],
|
|
46
|
-
[3, 'three'],
|
|
47
|
-
[4, 'four'],
|
|
48
|
-
[9, 'nine'],
|
|
49
|
-
[8, 'eight']
|
|
50
|
-
];
|
|
51
|
-
|
|
52
|
-
const tree = new BinaryTree(entries);
|
|
53
|
-
|
|
54
|
-
// Verify size
|
|
55
|
-
console.log(tree.size); // 9;
|
|
56
|
-
|
|
57
|
-
// Add new element
|
|
58
|
-
tree.set(10, 'ten');
|
|
59
|
-
console.log(tree.size); // 10;
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
### BinaryTree get and has operations
|
|
63
|
-
```typescript
|
|
64
|
-
const tree = new BinaryTree(
|
|
65
|
-
[
|
|
66
|
-
[5, 'five'],
|
|
67
|
-
[3, 'three'],
|
|
68
|
-
[7, 'seven'],
|
|
69
|
-
[1, 'one'],
|
|
70
|
-
[4, 'four'],
|
|
71
|
-
[6, 'six'],
|
|
72
|
-
[8, 'eight']
|
|
73
|
-
],
|
|
74
|
-
{ isMapMode: false }
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
// Check if key exists
|
|
78
|
-
console.log(tree.has(5)); // true;
|
|
79
|
-
console.log(tree.has(10)); // false;
|
|
80
|
-
|
|
81
|
-
// Get value by key
|
|
82
|
-
console.log(tree.get(3)); // 'three';
|
|
83
|
-
console.log(tree.get(7)); // 'seven';
|
|
84
|
-
console.log(tree.get(100)); // undefined;
|
|
85
|
-
|
|
86
|
-
// Get node structure
|
|
87
|
-
const node = tree.getNode(5);
|
|
88
|
-
console.log(node?.key); // 5;
|
|
89
|
-
console.log(node?.value); // 'five';
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### BinaryTree level-order traversal
|
|
93
|
-
```typescript
|
|
94
|
-
const tree = new BinaryTree([
|
|
95
|
-
[1, 'one'],
|
|
96
|
-
[2, 'two'],
|
|
97
|
-
[3, 'three'],
|
|
98
|
-
[4, 'four'],
|
|
99
|
-
[5, 'five'],
|
|
100
|
-
[6, 'six'],
|
|
101
|
-
[7, 'seven']
|
|
102
|
-
]);
|
|
103
|
-
|
|
104
|
-
// Binary tree maintains level-order insertion
|
|
105
|
-
// Complete binary tree structure
|
|
106
|
-
console.log(tree.size); // 7;
|
|
107
|
-
|
|
108
|
-
// Verify all keys are present
|
|
109
|
-
console.log(tree.has(1)); // true;
|
|
110
|
-
console.log(tree.has(4)); // true;
|
|
111
|
-
console.log(tree.has(7)); // true;
|
|
112
|
-
|
|
113
|
-
// Iterate through tree
|
|
114
|
-
const keys: number[] = [];
|
|
115
|
-
for (const [key] of tree) {
|
|
116
|
-
keys.push(key);
|
|
117
|
-
}
|
|
118
|
-
console.log(keys.length); // 7;
|
|
119
|
-
```
|
|
120
|
-
|
|
121
37
|
### determine loan approval using a decision tree
|
|
122
38
|
```typescript
|
|
123
39
|
// Decision tree structure
|