data-structure-typed 2.1.1 → 2.1.2
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/CHANGELOG.md +1 -1
- package/README.md +19 -7
- package/dist/cjs/index.cjs +22 -22
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.mjs +22 -22
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/bst.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +2 -2
- package/dist/types/data-structures/binary-tree/tree-counter.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1 -1
- package/dist/types/data-structures/heap/heap.d.ts +4 -4
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +1 -1
- package/dist/types/interfaces/binary-tree.d.ts +1 -1
- package/dist/umd/data-structure-typed.js +87 -165
- package/dist/umd/data-structure-typed.js.map +1 -1
- package/dist/umd/data-structure-typed.min.js +2 -2
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/jest.integration.config.js +7 -3
- package/package.json +11 -7
- package/src/data-structures/binary-tree/avl-tree-counter.ts +4 -4
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +1 -1
- package/src/data-structures/binary-tree/avl-tree.ts +2 -2
- package/src/data-structures/binary-tree/binary-tree.ts +4 -4
- package/src/data-structures/binary-tree/bst.ts +1 -1
- package/src/data-structures/binary-tree/red-black-tree.ts +2 -2
- package/src/data-structures/binary-tree/tree-counter.ts +4 -4
- package/src/data-structures/binary-tree/tree-multi-map.ts +1 -1
- package/src/data-structures/heap/heap.ts +5 -5
- package/src/data-structures/linked-list/singly-linked-list.ts +2 -2
- package/src/interfaces/binary-tree.ts +1 -1
- package/test/integration/compile.test.mjs +159 -0
- package/test/integration/compile.test.ts +176 -0
- package/test/integration/heap.test.js +1 -1
- package/test/integration/index.html +1 -1
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +3 -3
- package/{tsconfig-base.json → tsconfig.base.json} +0 -1
- package/tsconfig.test.json +1 -0
- package/{tsconfig-types.json → tsconfig.types.json} +1 -3
- package/tsup.config.js +2 -3
- package/dist/index.cjs +0 -13091
- package/dist/index.cjs.map +0 -1
- package/dist/index.js +0 -13013
- package/dist/index.js.map +0 -1
- package/test/integration/compile.js +0 -144
- package/test/integration/compile.mjs +0 -135
- package/test/integration/compile.ts +0 -171
- /package/{tsup.node.config.ts → tsup.node.config.js} +0 -0
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
var data_structure_typed_1 = require('data-structure-typed');
|
|
4
|
-
|
|
5
|
-
var orgArr = [6, 1, 2, 7, 5, 3, 4, 9, 8];
|
|
6
|
-
var orgStrArr = ['trie', 'trial', 'trick', 'trip', 'tree', 'trend', 'triangle', 'track', 'trace', 'transmit'];
|
|
7
|
-
var entries = [
|
|
8
|
-
[6, '6'],
|
|
9
|
-
[1, '1'],
|
|
10
|
-
[2, '2'],
|
|
11
|
-
[7, '7'],
|
|
12
|
-
[5, '5'],
|
|
13
|
-
[3, '3'],
|
|
14
|
-
[4, '4'],
|
|
15
|
-
[9, '9'],
|
|
16
|
-
[8, '8']
|
|
17
|
-
];
|
|
18
|
-
var queue = new data_structure_typed_1.Queue(orgArr);
|
|
19
|
-
queue.print();
|
|
20
|
-
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
|
|
21
|
-
var deque = new data_structure_typed_1.Deque(orgArr);
|
|
22
|
-
deque.print();
|
|
23
|
-
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
|
|
24
|
-
var sList = new data_structure_typed_1.SinglyLinkedList(orgArr);
|
|
25
|
-
sList.print();
|
|
26
|
-
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
|
|
27
|
-
var dList = new data_structure_typed_1.DoublyLinkedList(orgArr);
|
|
28
|
-
dList.print();
|
|
29
|
-
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
|
|
30
|
-
var stack = new data_structure_typed_1.Stack(orgArr);
|
|
31
|
-
stack.print();
|
|
32
|
-
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
|
|
33
|
-
var minHeap = new data_structure_typed_1.MinHeap(orgArr);
|
|
34
|
-
minHeap.print();
|
|
35
|
-
// [1, 5, 2, 7, 6, 3, 4, 9, 8]
|
|
36
|
-
var maxPQ = new data_structure_typed_1.MaxPriorityQueue(orgArr);
|
|
37
|
-
maxPQ.print();
|
|
38
|
-
// [9, 8, 4, 7, 5, 2, 3, 1, 6]
|
|
39
|
-
var biTree = new data_structure_typed_1.BinaryTree(entries);
|
|
40
|
-
biTree.print();
|
|
41
|
-
// ___6___
|
|
42
|
-
// / \
|
|
43
|
-
// ___1_ _2_
|
|
44
|
-
// / \ / \
|
|
45
|
-
// _7_ 5 3 4
|
|
46
|
-
// / \
|
|
47
|
-
// 9 8
|
|
48
|
-
var bst = new data_structure_typed_1.BST(entries);
|
|
49
|
-
bst.print();
|
|
50
|
-
// _____5___
|
|
51
|
-
// / \
|
|
52
|
-
// _2_ _7_
|
|
53
|
-
// / \ / \
|
|
54
|
-
// 1 3_ 6 8_
|
|
55
|
-
// \ \
|
|
56
|
-
// 4 9
|
|
57
|
-
var rbTree = new data_structure_typed_1.RedBlackTree(entries);
|
|
58
|
-
rbTree.print();
|
|
59
|
-
// ___4___
|
|
60
|
-
// / \
|
|
61
|
-
// _2_ _6___
|
|
62
|
-
// / \ / \
|
|
63
|
-
// 1 3 5 _8_
|
|
64
|
-
// / \
|
|
65
|
-
// 7 9
|
|
66
|
-
var avl = new data_structure_typed_1.AVLTree(entries);
|
|
67
|
-
avl.print();
|
|
68
|
-
// ___4___
|
|
69
|
-
// / \
|
|
70
|
-
// _2_ _6___
|
|
71
|
-
// / \ / \
|
|
72
|
-
// 1 3 5 _8_
|
|
73
|
-
// / \
|
|
74
|
-
// 7 9
|
|
75
|
-
var treeMulti = new data_structure_typed_1.TreeMultiMap(entries);
|
|
76
|
-
treeMulti.print();
|
|
77
|
-
// ___4___
|
|
78
|
-
// / \
|
|
79
|
-
// _2_ _6___
|
|
80
|
-
// / \ / \
|
|
81
|
-
// 1 3 5 _8_
|
|
82
|
-
// / \
|
|
83
|
-
// 7 9
|
|
84
|
-
var hm = new data_structure_typed_1.HashMap(entries);
|
|
85
|
-
hm.print();
|
|
86
|
-
// [[6, "6"], [1, "1"], [2, "2"], [7, "7"], [5, "5"], [3, "3"], [4, "4"], [9, "9"], [8, "8"]]
|
|
87
|
-
var rbTreeH = new data_structure_typed_1.RedBlackTree(hm);
|
|
88
|
-
rbTreeH.print();
|
|
89
|
-
// ___4___
|
|
90
|
-
// / \
|
|
91
|
-
// _2_ _6___
|
|
92
|
-
// / \ / \
|
|
93
|
-
// 1 3 5 _8_
|
|
94
|
-
// / \
|
|
95
|
-
// 7 9
|
|
96
|
-
var pq = new data_structure_typed_1.MinPriorityQueue(orgArr);
|
|
97
|
-
pq.print();
|
|
98
|
-
// [1, 5, 2, 7, 6, 3, 4, 9, 8]
|
|
99
|
-
var bst1 = new data_structure_typed_1.BST(pq);
|
|
100
|
-
bst1.print();
|
|
101
|
-
// _____5___
|
|
102
|
-
// / \
|
|
103
|
-
// _2_ _7_
|
|
104
|
-
// / \ / \
|
|
105
|
-
// 1 3_ 6 8_
|
|
106
|
-
// \ \
|
|
107
|
-
// 4 9
|
|
108
|
-
var dq1 = new data_structure_typed_1.Deque(orgArr);
|
|
109
|
-
dq1.print();
|
|
110
|
-
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
|
|
111
|
-
var rbTree1 = new data_structure_typed_1.RedBlackTree(dq1);
|
|
112
|
-
rbTree1.print();
|
|
113
|
-
// _____5___
|
|
114
|
-
// / \
|
|
115
|
-
// _2___ _7___
|
|
116
|
-
// / \ / \
|
|
117
|
-
// 1 _4 6 _9
|
|
118
|
-
// / /
|
|
119
|
-
// 3 8
|
|
120
|
-
var trie2 = new data_structure_typed_1.Trie(orgStrArr);
|
|
121
|
-
trie2.print();
|
|
122
|
-
// ['trie', 'trial', 'triangle', 'trick', 'trip', 'tree', 'trend', 'track', 'trace', 'transmit']
|
|
123
|
-
var heap2 = new data_structure_typed_1.Heap(trie2, {
|
|
124
|
-
comparator: function (a, b) {
|
|
125
|
-
return Number(a) - Number(b);
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
heap2.print();
|
|
129
|
-
// ['transmit', 'trace', 'tree', 'trend', 'track', 'trial', 'trip', 'trie', 'trick', 'triangle']
|
|
130
|
-
var dq2 = new data_structure_typed_1.Deque(heap2);
|
|
131
|
-
dq2.print();
|
|
132
|
-
// ['transmit', 'trace', 'tree', 'trend', 'track', 'trial', 'trip', 'trie', 'trick', 'triangle']
|
|
133
|
-
var entries2 = dq2.map(function (el, i) {
|
|
134
|
-
return [i, el];
|
|
135
|
-
});
|
|
136
|
-
var avl2 = new data_structure_typed_1.AVLTree(entries2);
|
|
137
|
-
avl2.print();
|
|
138
|
-
// ___3_______
|
|
139
|
-
// / \
|
|
140
|
-
// _1_ ___7_
|
|
141
|
-
// / \ / \
|
|
142
|
-
// 0 2 _5_ 8_
|
|
143
|
-
// / \ \
|
|
144
|
-
// 4 6 9
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { AVLTree, BinaryTree, BST, Deque, DoublyLinkedList, HashMap, Heap, MaxPriorityQueue, MinHeap, MinPriorityQueue, Queue, RedBlackTree, SinglyLinkedList, Stack, TreeMultiMap, Trie } from 'data-structure-typed';
|
|
2
|
-
const orgArr = [6, 1, 2, 7, 5, 3, 4, 9, 8];
|
|
3
|
-
const orgStrArr = ['trie', 'trial', 'trick', 'trip', 'tree', 'trend', 'triangle', 'track', 'trace', 'transmit'];
|
|
4
|
-
const entries = [
|
|
5
|
-
[6, '6'],
|
|
6
|
-
[1, '1'],
|
|
7
|
-
[2, '2'],
|
|
8
|
-
[7, '7'],
|
|
9
|
-
[5, '5'],
|
|
10
|
-
[3, '3'],
|
|
11
|
-
[4, '4'],
|
|
12
|
-
[9, '9'],
|
|
13
|
-
[8, '8']
|
|
14
|
-
];
|
|
15
|
-
const queue = new Queue(orgArr);
|
|
16
|
-
|
|
17
|
-
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
|
|
18
|
-
const deque = new Deque(orgArr);
|
|
19
|
-
|
|
20
|
-
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
|
|
21
|
-
const sList = new SinglyLinkedList(orgArr);
|
|
22
|
-
|
|
23
|
-
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
|
|
24
|
-
const dList = new DoublyLinkedList(orgArr);
|
|
25
|
-
|
|
26
|
-
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
|
|
27
|
-
const stack = new Stack(orgArr);
|
|
28
|
-
|
|
29
|
-
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
|
|
30
|
-
const minHeap = new MinHeap(orgArr);
|
|
31
|
-
|
|
32
|
-
// [1, 5, 2, 7, 6, 3, 4, 9, 8]
|
|
33
|
-
const maxPQ = new MaxPriorityQueue(orgArr);
|
|
34
|
-
|
|
35
|
-
// [9, 8, 4, 7, 5, 2, 3, 1, 6]
|
|
36
|
-
const biTree = new BinaryTree(entries);
|
|
37
|
-
|
|
38
|
-
// ___6___
|
|
39
|
-
// / \
|
|
40
|
-
// ___1_ _2_
|
|
41
|
-
// / \ / \
|
|
42
|
-
// _7_ 5 3 4
|
|
43
|
-
// / \
|
|
44
|
-
// 9 8
|
|
45
|
-
const bst = new BST(entries);
|
|
46
|
-
|
|
47
|
-
// _____5___
|
|
48
|
-
// / \
|
|
49
|
-
// _2_ _7_
|
|
50
|
-
// / \ / \
|
|
51
|
-
// 1 3_ 6 8_
|
|
52
|
-
// \ \
|
|
53
|
-
// 4 9
|
|
54
|
-
const rbTree = new RedBlackTree(entries);
|
|
55
|
-
|
|
56
|
-
// ___4___
|
|
57
|
-
// / \
|
|
58
|
-
// _2_ _6___
|
|
59
|
-
// / \ / \
|
|
60
|
-
// 1 3 5 _8_
|
|
61
|
-
// / \
|
|
62
|
-
// 7 9
|
|
63
|
-
const avl = new AVLTree(entries);
|
|
64
|
-
|
|
65
|
-
// ___4___
|
|
66
|
-
// / \
|
|
67
|
-
// _2_ _6___
|
|
68
|
-
// / \ / \
|
|
69
|
-
// 1 3 5 _8_
|
|
70
|
-
// / \
|
|
71
|
-
// 7 9
|
|
72
|
-
const treeMulti = new TreeMultiMap(entries);
|
|
73
|
-
|
|
74
|
-
// ___4___
|
|
75
|
-
// / \
|
|
76
|
-
// _2_ _6___
|
|
77
|
-
// / \ / \
|
|
78
|
-
// 1 3 5 _8_
|
|
79
|
-
// / \
|
|
80
|
-
// 7 9
|
|
81
|
-
const hm = new HashMap(entries);
|
|
82
|
-
|
|
83
|
-
// [[6, "6"], [1, "1"], [2, "2"], [7, "7"], [5, "5"], [3, "3"], [4, "4"], [9, "9"], [8, "8"]]
|
|
84
|
-
const rbTreeH = new RedBlackTree(hm);
|
|
85
|
-
|
|
86
|
-
// ___4___
|
|
87
|
-
// / \
|
|
88
|
-
// _2_ _6___
|
|
89
|
-
// / \ / \
|
|
90
|
-
// 1 3 5 _8_
|
|
91
|
-
// / \
|
|
92
|
-
// 7 9
|
|
93
|
-
const pq = new MinPriorityQueue(orgArr);
|
|
94
|
-
|
|
95
|
-
// [1, 5, 2, 7, 6, 3, 4, 9, 8]
|
|
96
|
-
const bst1 = new BST(pq);
|
|
97
|
-
|
|
98
|
-
// _____5___
|
|
99
|
-
// / \
|
|
100
|
-
// _2_ _7_
|
|
101
|
-
// / \ / \
|
|
102
|
-
// 1 3_ 6 8_
|
|
103
|
-
// \ \
|
|
104
|
-
// 4 9
|
|
105
|
-
const dq1 = new Deque(orgArr);
|
|
106
|
-
|
|
107
|
-
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
|
|
108
|
-
const rbTree1 = new RedBlackTree(dq1);
|
|
109
|
-
|
|
110
|
-
// _____5___
|
|
111
|
-
// / \
|
|
112
|
-
// _2___ _7___
|
|
113
|
-
// / \ / \
|
|
114
|
-
// 1 _4 6 _9
|
|
115
|
-
// / /
|
|
116
|
-
// 3 8
|
|
117
|
-
const trie2 = new Trie(orgStrArr);
|
|
118
|
-
|
|
119
|
-
// ['trie', 'trial', 'triangle', 'trick', 'trip', 'tree', 'trend', 'track', 'trace', 'transmit']
|
|
120
|
-
const heap2 = new Heap(trie2, { comparator: (a, b) => Number(a) - Number(b) });
|
|
121
|
-
|
|
122
|
-
// ['transmit', 'trace', 'tree', 'trend', 'track', 'trial', 'trip', 'trie', 'trick', 'triangle']
|
|
123
|
-
const dq2 = new Deque(heap2);
|
|
124
|
-
|
|
125
|
-
// ['transmit', 'trace', 'tree', 'trend', 'track', 'trial', 'trip', 'trie', 'trick', 'triangle']
|
|
126
|
-
const entries2 = dq2.map((el, i) => [i, el]);
|
|
127
|
-
const avl2 = new AVLTree(entries2);
|
|
128
|
-
avl2.print();
|
|
129
|
-
// ___3_______
|
|
130
|
-
// / \
|
|
131
|
-
// _1_ ___7_
|
|
132
|
-
// / \ / \
|
|
133
|
-
// 0 2 _5_ 8_
|
|
134
|
-
// / \ \
|
|
135
|
-
// 4 6 9
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AVLTree,
|
|
3
|
-
BinaryTree,
|
|
4
|
-
BST,
|
|
5
|
-
Deque,
|
|
6
|
-
DoublyLinkedList,
|
|
7
|
-
HashMap,
|
|
8
|
-
Heap,
|
|
9
|
-
MaxPriorityQueue,
|
|
10
|
-
MinHeap,
|
|
11
|
-
MinPriorityQueue,
|
|
12
|
-
Queue,
|
|
13
|
-
RedBlackTree,
|
|
14
|
-
SinglyLinkedList,
|
|
15
|
-
Stack,
|
|
16
|
-
TreeMultiMap,
|
|
17
|
-
Trie
|
|
18
|
-
} from 'data-structure-typed';
|
|
19
|
-
|
|
20
|
-
const orgArr = [6, 1, 2, 7, 5, 3, 4, 9, 8];
|
|
21
|
-
const orgStrArr = ['trie', 'trial', 'trick', 'trip', 'tree', 'trend', 'triangle', 'track', 'trace', 'transmit'];
|
|
22
|
-
const entries: [number, string][] = [
|
|
23
|
-
[6, '6'],
|
|
24
|
-
[1, '1'],
|
|
25
|
-
[2, '2'],
|
|
26
|
-
[7, '7'],
|
|
27
|
-
[5, '5'],
|
|
28
|
-
[3, '3'],
|
|
29
|
-
[4, '4'],
|
|
30
|
-
[9, '9'],
|
|
31
|
-
[8, '8']
|
|
32
|
-
];
|
|
33
|
-
|
|
34
|
-
const queue = new Queue(orgArr);
|
|
35
|
-
queue.print();
|
|
36
|
-
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
|
|
37
|
-
|
|
38
|
-
const deque = new Deque(orgArr);
|
|
39
|
-
deque.print();
|
|
40
|
-
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
|
|
41
|
-
|
|
42
|
-
const sList = new SinglyLinkedList(orgArr);
|
|
43
|
-
sList.print();
|
|
44
|
-
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
|
|
45
|
-
|
|
46
|
-
const dList = new DoublyLinkedList(orgArr);
|
|
47
|
-
dList.print();
|
|
48
|
-
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
|
|
49
|
-
|
|
50
|
-
const stack = new Stack(orgArr);
|
|
51
|
-
stack.print();
|
|
52
|
-
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
|
|
53
|
-
|
|
54
|
-
const minHeap = new MinHeap(orgArr);
|
|
55
|
-
minHeap.print();
|
|
56
|
-
// [1, 5, 2, 7, 6, 3, 4, 9, 8]
|
|
57
|
-
|
|
58
|
-
const maxPQ = new MaxPriorityQueue(orgArr);
|
|
59
|
-
maxPQ.print();
|
|
60
|
-
// [9, 8, 4, 7, 5, 2, 3, 1, 6]
|
|
61
|
-
|
|
62
|
-
const biTree = new BinaryTree(entries);
|
|
63
|
-
biTree.print();
|
|
64
|
-
// ___6___
|
|
65
|
-
// / \
|
|
66
|
-
// ___1_ _2_
|
|
67
|
-
// / \ / \
|
|
68
|
-
// _7_ 5 3 4
|
|
69
|
-
// / \
|
|
70
|
-
// 9 8
|
|
71
|
-
|
|
72
|
-
const bst = new BST(entries);
|
|
73
|
-
bst.print();
|
|
74
|
-
// _____5___
|
|
75
|
-
// / \
|
|
76
|
-
// _2_ _7_
|
|
77
|
-
// / \ / \
|
|
78
|
-
// 1 3_ 6 8_
|
|
79
|
-
// \ \
|
|
80
|
-
// 4 9
|
|
81
|
-
|
|
82
|
-
const rbTree = new RedBlackTree(entries);
|
|
83
|
-
rbTree.print();
|
|
84
|
-
// ___4___
|
|
85
|
-
// / \
|
|
86
|
-
// _2_ _6___
|
|
87
|
-
// / \ / \
|
|
88
|
-
// 1 3 5 _8_
|
|
89
|
-
// / \
|
|
90
|
-
// 7 9
|
|
91
|
-
|
|
92
|
-
const avl = new AVLTree(entries);
|
|
93
|
-
avl.print();
|
|
94
|
-
// ___4___
|
|
95
|
-
// / \
|
|
96
|
-
// _2_ _6___
|
|
97
|
-
// / \ / \
|
|
98
|
-
// 1 3 5 _8_
|
|
99
|
-
// / \
|
|
100
|
-
// 7 9
|
|
101
|
-
|
|
102
|
-
const treeMulti = new TreeMultiMap(entries);
|
|
103
|
-
treeMulti.print();
|
|
104
|
-
// ___4___
|
|
105
|
-
// / \
|
|
106
|
-
// _2_ _6___
|
|
107
|
-
// / \ / \
|
|
108
|
-
// 1 3 5 _8_
|
|
109
|
-
// / \
|
|
110
|
-
// 7 9
|
|
111
|
-
|
|
112
|
-
const hm = new HashMap(entries);
|
|
113
|
-
hm.print();
|
|
114
|
-
// [[6, "6"], [1, "1"], [2, "2"], [7, "7"], [5, "5"], [3, "3"], [4, "4"], [9, "9"], [8, "8"]]
|
|
115
|
-
|
|
116
|
-
const rbTreeH = new RedBlackTree(hm);
|
|
117
|
-
rbTreeH.print();
|
|
118
|
-
// ___4___
|
|
119
|
-
// / \
|
|
120
|
-
// _2_ _6___
|
|
121
|
-
// / \ / \
|
|
122
|
-
// 1 3 5 _8_
|
|
123
|
-
// / \
|
|
124
|
-
// 7 9
|
|
125
|
-
|
|
126
|
-
const pq = new MinPriorityQueue(orgArr);
|
|
127
|
-
pq.print();
|
|
128
|
-
// [1, 5, 2, 7, 6, 3, 4, 9, 8]
|
|
129
|
-
|
|
130
|
-
const bst1 = new BST(pq);
|
|
131
|
-
bst1.print();
|
|
132
|
-
// _____5___
|
|
133
|
-
// / \
|
|
134
|
-
// _2_ _7_
|
|
135
|
-
// / \ / \
|
|
136
|
-
// 1 3_ 6 8_
|
|
137
|
-
// \ \
|
|
138
|
-
// 4 9
|
|
139
|
-
|
|
140
|
-
const dq1 = new Deque(orgArr);
|
|
141
|
-
dq1.print();
|
|
142
|
-
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
|
|
143
|
-
const rbTree1 = new RedBlackTree(dq1);
|
|
144
|
-
rbTree1.print();
|
|
145
|
-
// _____5___
|
|
146
|
-
// / \
|
|
147
|
-
// _2___ _7___
|
|
148
|
-
// / \ / \
|
|
149
|
-
// 1 _4 6 _9
|
|
150
|
-
// / /
|
|
151
|
-
// 3 8
|
|
152
|
-
|
|
153
|
-
const trie2 = new Trie(orgStrArr);
|
|
154
|
-
trie2.print();
|
|
155
|
-
// ['trie', 'trial', 'triangle', 'trick', 'trip', 'tree', 'trend', 'track', 'trace', 'transmit']
|
|
156
|
-
const heap2 = new Heap(trie2, { comparator: (a, b) => Number(a) - Number(b) });
|
|
157
|
-
heap2.print();
|
|
158
|
-
// ['transmit', 'trace', 'tree', 'trend', 'track', 'trial', 'trip', 'trie', 'trick', 'triangle']
|
|
159
|
-
const dq2 = new Deque(heap2);
|
|
160
|
-
dq2.print();
|
|
161
|
-
// ['transmit', 'trace', 'tree', 'trend', 'track', 'trial', 'trip', 'trie', 'trick', 'triangle']
|
|
162
|
-
const entries2 = dq2.map((el, i) => [i, el]);
|
|
163
|
-
const avl2 = new AVLTree(entries2);
|
|
164
|
-
avl2.print();
|
|
165
|
-
// ___3_______
|
|
166
|
-
// / \
|
|
167
|
-
// _1_ ___7_
|
|
168
|
-
// / \ / \
|
|
169
|
-
// 0 2 _5_ 8_
|
|
170
|
-
// / \ \
|
|
171
|
-
// 4 6 9
|
|
File without changes
|