bst-typed 1.3.1

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 ADDED
@@ -0,0 +1,805 @@
1
+ # What
2
+ ## Brief
3
+ This is a standalone BST (Binary Search Tree) data structure from the data-structure-typed collection. If you wish to access more data structures or advanced features, you can transition to directly installing the complete [data-structure-typed](https://www.npmjs.com/package/data-structure-typed) package
4
+
5
+
6
+ # How
7
+
8
+ ## install
9
+ ### npm
10
+ ```bash
11
+ npm i bst-typed
12
+ ```
13
+ ### yarn
14
+ ```bash
15
+ yarn add bst-typed
16
+ ```
17
+ ### methods
18
+ ![](https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/methods-8bit/bst.png?raw=true)
19
+ ### snippet
20
+ #### TS
21
+ ```typescript
22
+ import {BST, BSTNode} from 'data-structure-typed';
23
+ // /* or if you prefer */ import {BST, BSTNode} from 'bst-typed';
24
+
25
+ const bst = new BST();
26
+ bst instanceof BST; // true
27
+ bst.add(11);
28
+ bst.add(3);
29
+ const idsAndValues = [15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5];
30
+ bst.addMany(idsAndValues);
31
+ bst.root instanceof BSTNode; // true
32
+
33
+ if (bst.root) bst.root.id; // 11
34
+
35
+ bst.size; // 16
36
+
37
+ bst.has(6); // true
38
+
39
+ const node6 = bst.get(6);
40
+ node6 && bst.getHeight(6); // 2
41
+ node6 && bst.getDepth(6); // 3
42
+
43
+ const nodeId10 = bst.get(10);
44
+ nodeId10?.id; // 10
45
+
46
+ const nodeVal9 = bst.get(9, 'val');
47
+ nodeVal9?.id; // 9
48
+
49
+
50
+ const leftMost = bst.getLeftMost();
51
+ leftMost?.id; // 1
52
+
53
+ const node15 = bst.get(15);
54
+ const minNodeBySpecificNode = node15 && bst.getLeftMost(node15);
55
+ minNodeBySpecificNode?.id; // 12
56
+
57
+ const subTreeSum = node15 && bst.subTreeSum(15);
58
+ subTreeSum; // 70
59
+
60
+ const lesserSum = bst.lesserSum(10);
61
+ lesserSum; // 45
62
+
63
+ node15 instanceof BSTNode; // true
64
+
65
+ const node11 = bst.get(11);
66
+ node11 instanceof BSTNode; // true
67
+
68
+ const dfsInorderNodes = bst.DFS('in', 'node');
69
+ dfsInorderNodes[0].id; // 1
70
+ dfsInorderNodes[dfsInorderNodes.length - 1].id; // 16
71
+
72
+ bst.perfectlyBalance();
73
+ bst.isPerfectlyBalanced(); // true
74
+
75
+ const bfsNodesAfterBalanced = bst.BFS('node');
76
+ bfsNodesAfterBalanced[0].id; // 8);
77
+ bfsNodesAfterBalanced[bfsNodesAfterBalanced.length - 1].id; // 16
78
+
79
+ const removed11 = bst.remove(11, true);
80
+ removed11 instanceof Array; // true
81
+
82
+
83
+ if (removed11[0].deleted) removed11[0].deleted.id; // 11
84
+
85
+ bst.isAVLBalanced(); // true
86
+
87
+ bst.getHeight(15); // 1
88
+
89
+ const removed1 = bst.remove(1, true);
90
+ removed1 instanceof Array; // true
91
+
92
+ if (removed1[0].deleted) removed1[0].deleted.id; // 1
93
+
94
+ bst.isAVLBalanced(); // true
95
+
96
+ bst.getHeight(); // 4
97
+
98
+ const removed4 = bst.remove(4, true);
99
+ removed4 instanceof Array; // true
100
+
101
+ if (removed4[0].deleted) removed4[0].deleted.id; // 4
102
+ bst.isAVLBalanced(); // true
103
+ bst.getHeight(); // 4
104
+
105
+ const removed10 = bst.remove(10, true);
106
+
107
+ if (removed10[0].deleted) removed10[0].deleted.id; // 10
108
+ bst.isAVLBalanced(); // false
109
+ bst.getHeight(); // 4
110
+
111
+ const removed15 = bst.remove(15, true);
112
+
113
+ if (removed15[0].deleted) removed15[0].deleted.id; // 15
114
+
115
+ bst.isAVLBalanced(); // true
116
+ bst.getHeight(); // 3
117
+
118
+ const removed5 = bst.remove(5, true);
119
+
120
+ if (removed5[0].deleted) removed5[0].deleted.id; // 5
121
+
122
+ bst.isAVLBalanced(); // true
123
+ bst.getHeight(); // 3
124
+
125
+ const removed13 = bst.remove(13, true);
126
+ if (removed13[0].deleted) removed13[0].deleted.id; // 13
127
+ bst.isAVLBalanced(); // true
128
+ bst.getHeight(); // 3
129
+
130
+ const removed3 = bst.remove(3, true);
131
+ if (removed3[0].deleted) removed3[0].deleted.id; // 3
132
+ bst.isAVLBalanced(); // false
133
+ bst.getHeight(); // 3
134
+
135
+ const removed8 = bst.remove(8, true);
136
+ if (removed8[0].deleted) removed8[0].deleted.id; // 8
137
+ bst.isAVLBalanced(); // true
138
+ bst.getHeight(); // 3
139
+
140
+ const removed6 = bst.remove(6, true);
141
+ if (removed6[0].deleted) removed6[0].deleted.id; // 6
142
+ bst.remove(6, true).length; // 0
143
+ bst.isAVLBalanced(); // false
144
+ bst.getHeight(); // 3
145
+
146
+ const removed7 = bst.remove(7, true);
147
+ if (removed7[0].deleted) removed7[0].deleted.id; // 7
148
+ bst.isAVLBalanced(); // false
149
+ bst.getHeight(); // 3
150
+
151
+ const removed9 = bst.remove(9, true);
152
+ if (removed9[0].deleted) removed9[0].deleted.id; // 9
153
+ bst.isAVLBalanced(); // false
154
+ bst.getHeight(); // 3
155
+
156
+ const removed14 = bst.remove(14, true);
157
+ if (removed14[0].deleted) removed14[0].deleted.id; // 14
158
+ bst.isAVLBalanced(); // false
159
+ bst.getHeight(); // 2
160
+
161
+ bst.isAVLBalanced(); // false
162
+
163
+ const bfsIDs = bst.BFS();
164
+ bfsIDs[0]; // 2
165
+ bfsIDs[1]; // 12
166
+ bfsIDs[2]; // 16
167
+
168
+ const bfsNodes = bst.BFS('node');
169
+ bfsNodes[0].id; // 2
170
+ bfsNodes[1].id; // 12
171
+ bfsNodes[2].id; // 16
172
+ ```
173
+ #### JS
174
+ ```javascript
175
+ const {BST, BSTNode} = require('data-structure-typed');
176
+ // /* or if you prefer */ const {BST, BSTNode} = require('bst-typed');
177
+
178
+ const bst = new BST();
179
+ bst instanceof BST; // true
180
+ bst.add(11);
181
+ bst.add(3);
182
+ const idsAndValues = [15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5];
183
+ bst.addMany(idsAndValues);
184
+ bst.root instanceof BSTNode; // true
185
+
186
+ if (bst.root) bst.root.id; // 11
187
+
188
+ bst.size; // 16
189
+
190
+ bst.has(6); // true
191
+
192
+ const node6 = bst.get(6);
193
+ node6 && bst.getHeight(6); // 2
194
+ node6 && bst.getDepth(6); // 3
195
+
196
+ const nodeId10 = bst.get(10);
197
+ nodeId10?.id; // 10
198
+
199
+ const nodeVal9 = bst.get(9, 'val');
200
+ nodeVal9?.id; // 9
201
+
202
+
203
+ const leftMost = bst.getLeftMost();
204
+ leftMost?.id; // 1
205
+
206
+ const node15 = bst.get(15);
207
+ const minNodeBySpecificNode = node15 && bst.getLeftMost(node15);
208
+ minNodeBySpecificNode?.id; // 12
209
+
210
+ const subTreeSum = node15 && bst.subTreeSum(15);
211
+ subTreeSum; // 70
212
+
213
+ const lesserSum = bst.lesserSum(10);
214
+ lesserSum; // 45
215
+
216
+ node15 instanceof BSTNode; // true
217
+
218
+ const node11 = bst.get(11);
219
+ node11 instanceof BSTNode; // true
220
+
221
+ const dfsInorderNodes = bst.DFS('in', 'node');
222
+ dfsInorderNodes[0].id; // 1
223
+ dfsInorderNodes[dfsInorderNodes.length - 1].id; // 16
224
+
225
+ bst.perfectlyBalance();
226
+ bst.isPerfectlyBalanced(); // true
227
+
228
+ const bfsNodesAfterBalanced = bst.BFS('node');
229
+ bfsNodesAfterBalanced[0].id; // 8);
230
+ bfsNodesAfterBalanced[bfsNodesAfterBalanced.length - 1].id; // 16
231
+
232
+ const removed11 = bst.remove(11, true);
233
+ removed11 instanceof Array; // true
234
+
235
+
236
+ if (removed11[0].deleted) removed11[0].deleted.id; // 11
237
+
238
+ bst.isAVLBalanced(); // true
239
+
240
+ bst.getHeight(15); // 1
241
+
242
+ const removed1 = bst.remove(1, true);
243
+ removed1 instanceof Array; // true
244
+
245
+ if (removed1[0].deleted) removed1[0].deleted.id; // 1
246
+
247
+ bst.isAVLBalanced(); // true
248
+
249
+ bst.getHeight(); // 4
250
+
251
+ const removed4 = bst.remove(4, true);
252
+ removed4 instanceof Array; // true
253
+
254
+ if (removed4[0].deleted) removed4[0].deleted.id; // 4
255
+ bst.isAVLBalanced(); // true
256
+ bst.getHeight(); // 4
257
+
258
+ const removed10 = bst.remove(10, true);
259
+
260
+ if (removed10[0].deleted) removed10[0].deleted.id; // 10
261
+ bst.isAVLBalanced(); // false
262
+ bst.getHeight(); // 4
263
+
264
+ const removed15 = bst.remove(15, true);
265
+
266
+ if (removed15[0].deleted) removed15[0].deleted.id; // 15
267
+
268
+ bst.isAVLBalanced(); // true
269
+ bst.getHeight(); // 3
270
+
271
+ const removed5 = bst.remove(5, true);
272
+
273
+ if (removed5[0].deleted) removed5[0].deleted.id; // 5
274
+
275
+ bst.isAVLBalanced(); // true
276
+ bst.getHeight(); // 3
277
+
278
+ const removed13 = bst.remove(13, true);
279
+ if (removed13[0].deleted) removed13[0].deleted.id; // 13
280
+ bst.isAVLBalanced(); // true
281
+ bst.getHeight(); // 3
282
+
283
+ const removed3 = bst.remove(3, true);
284
+ if (removed3[0].deleted) removed3[0].deleted.id; // 3
285
+ bst.isAVLBalanced(); // false
286
+ bst.getHeight(); // 3
287
+
288
+ const removed8 = bst.remove(8, true);
289
+ if (removed8[0].deleted) removed8[0].deleted.id; // 8
290
+ bst.isAVLBalanced(); // true
291
+ bst.getHeight(); // 3
292
+
293
+ const removed6 = bst.remove(6, true);
294
+ if (removed6[0].deleted) removed6[0].deleted.id; // 6
295
+ bst.remove(6, true).length; // 0
296
+ bst.isAVLBalanced(); // false
297
+ bst.getHeight(); // 3
298
+
299
+ const removed7 = bst.remove(7, true);
300
+ if (removed7[0].deleted) removed7[0].deleted.id; // 7
301
+ bst.isAVLBalanced(); // false
302
+ bst.getHeight(); // 3
303
+
304
+ const removed9 = bst.remove(9, true);
305
+ if (removed9[0].deleted) removed9[0].deleted.id; // 9
306
+ bst.isAVLBalanced(); // false
307
+ bst.getHeight(); // 3
308
+
309
+ const removed14 = bst.remove(14, true);
310
+ if (removed14[0].deleted) removed14[0].deleted.id; // 14
311
+ bst.isAVLBalanced(); // false
312
+ bst.getHeight(); // 2
313
+
314
+ bst.isAVLBalanced(); // false
315
+
316
+ const bfsIDs = bst.BFS();
317
+ bfsIDs[0]; // 2
318
+ bfsIDs[1]; // 12
319
+ bfsIDs[2]; // 16
320
+
321
+ const bfsNodes = bst.BFS('node');
322
+ bfsNodes[0].id; // 2
323
+ bfsNodes[1].id; // 12
324
+ bfsNodes[2].id; // 16
325
+ ```
326
+
327
+
328
+ ## API docs & Examples
329
+
330
+ [API Docs](https://data-structure-typed-docs.vercel.app)
331
+
332
+ [Live Examples](https://data-structure-typed-examples.vercel.app)
333
+
334
+ <a href="https://github.com/zrwusa/data-structure-typed-examples" target="_blank">Examples Repository</a>
335
+
336
+ ## Data Structures
337
+
338
+ <table>
339
+ <thead>
340
+ <tr>
341
+ <th>Data Structure</th>
342
+ <th>Unit Test</th>
343
+ <th>Performance Test</th>
344
+ <th>API Documentation</th>
345
+ <th>Implemented</th>
346
+ </tr>
347
+ </thead>
348
+ <tbody>
349
+ <tr>
350
+ <td>Binary Tree</td>
351
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""/>
352
+ </td>
353
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""/>
354
+ </td>
355
+ <td><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryTree.html"><span>Binary Tree</span></a></td>
356
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
357
+ </tr>
358
+ <tr>
359
+ <td>Binary Search Tree (BST)</td>
360
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
361
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
362
+ <td><a href="https://data-structure-typed-docs.vercel.app/classes/BST.html"><span>BST</span></a></td>
363
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
364
+ </tr>
365
+ <tr>
366
+ <td>AVL Tree</td>
367
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
368
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
369
+ <td><a href="https://data-structure-typed-docs.vercel.app/classes/AVLTree.html"><span>AVLTree</span></a></td>
370
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
371
+ </tr>
372
+ <tr>
373
+ <td>Tree Multiset</td>
374
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
375
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
376
+ <td><a href="https://data-structure-typed-docs.vercel.app/classes/TreeMultiset.html"><span>TreeMultiset</span></a></td>
377
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
378
+ </tr>
379
+ <tr>
380
+ <td>Segment Tree</td>
381
+ <td></td>
382
+ <td></td>
383
+ <td><a href="https://data-structure-typed-docs.vercel.app/classes/SegmentTree.html"><span>SegmentTree</span></a></td>
384
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
385
+ </tr>
386
+ <tr>
387
+ <td>Binary Indexed Tree</td>
388
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
389
+ <td></td>
390
+ <td><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryIndexedTree.html"><span>BinaryIndexedTree</span></a></td>
391
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
392
+ </tr>
393
+ <tr>
394
+ <td>Graph</td>
395
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
396
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
397
+ <td><a href="https://data-structure-typed-docs.vercel.app/classes/AbstractGraph.html"><span>AbstractGraph</span></a></td>
398
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
399
+ </tr>
400
+ <tr>
401
+ <td>Directed Graph</td>
402
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
403
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
404
+ <td><a href="https://data-structure-typed-docs.vercel.app/classes/DirectedGraph.html"><span>DirectedGraph</span></a></td>
405
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
406
+ </tr>
407
+ <tr>
408
+ <td>Undirected Graph</td>
409
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
410
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
411
+ <td><a href="https://data-structure-typed-docs.vercel.app/classes/UndirectedGraph.html"><span>UndirectedGraph</span></a></td>
412
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
413
+ </tr>
414
+ <tr>
415
+ <td>Linked List</td>
416
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
417
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
418
+ <td><a href="https://data-structure-typed-docs.vercel.app/classes/SinglyLinkedList.html"><span>SinglyLinkedList</span></a></td>
419
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
420
+ </tr>
421
+ <tr>
422
+ <td>Singly Linked List</td>
423
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
424
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
425
+ <td><a href="https://data-structure-typed-docs.vercel.app/classes/SinglyLinkedList.html"><span>SinglyLinkedList</span></a></td>
426
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
427
+ </tr>
428
+ <tr>
429
+ <td>Doubly Linked List</td>
430
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
431
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
432
+ <td><a href="https://data-structure-typed-docs.vercel.app/classes/DoublyLinkedList.html"><span>DoublyLinkedList</span></a></td>
433
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
434
+ </tr>
435
+ <tr>
436
+ <td>Queue</td>
437
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
438
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
439
+ <td><a href="https://data-structure-typed-docs.vercel.app/classes/Queue.html"><span>Queue</span></a></td>
440
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
441
+ </tr>
442
+ <tr>
443
+ <td>Object Deque</td>
444
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
445
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
446
+ <td><a href="https://data-structure-typed-docs.vercel.app/classes/ObjectDeque.html"><span>ObjectDeque</span></a></td>
447
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
448
+ </tr>
449
+ <tr>
450
+ <td>Array Deque</td>
451
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
452
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
453
+ <td><a href="https://data-structure-typed-docs.vercel.app/classes/ArrayDeque.html"><span>ArrayDeque</span></a></td>
454
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
455
+ </tr>
456
+ <tr>
457
+ <td>Stack</td>
458
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
459
+ <td></td>
460
+ <td><a href="https://data-structure-typed-docs.vercel.app/classes/Stack.html"><span>Stack</span></a></td>
461
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
462
+ </tr>
463
+
464
+ [//]: # (<tr>)
465
+
466
+ [//]: # (<td>Hash</td>)
467
+
468
+ [//]: # (<td></td>)
469
+
470
+ [//]: # (<td></td>)
471
+
472
+ [//]: # (<td><a href="https://data-structure-typed-docs.vercel.app/classes/HashTable.html"><span>HashTable</span></a></td>)
473
+
474
+ [//]: # (<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>)
475
+
476
+ [//]: # (</tr>)
477
+ <tr>
478
+ <td>Coordinate Set</td>
479
+ <td></td>
480
+ <td></td>
481
+ <td><a href="https://data-structure-typed-docs.vercel.app/classes/CoordinateSet.html"><span>CoordinateSet</span></a></td>
482
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
483
+ </tr>
484
+ <tr>
485
+ <td>Coordinate Map</td>
486
+ <td></td>
487
+ <td></td>
488
+ <td><a href="https://data-structure-typed-docs.vercel.app/classes/CoordinateMap.html"><span>CoordinateMap</span></a></td>
489
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
490
+ </tr>
491
+ <tr>
492
+ <td>Heap</td>
493
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
494
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
495
+ <td><a href="https://data-structure-typed-docs.vercel.app/classes/Heap.html"><span>Heap</span></a></td>
496
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
497
+ </tr>
498
+ <tr>
499
+ <td>Priority Queue</td>
500
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
501
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
502
+ <td><a href="https://data-structure-typed-docs.vercel.app/classes/PriorityQueue.html"><span>PriorityQueue</span></a></td>
503
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
504
+ </tr>
505
+ <tr>
506
+ <td>Max Priority Queue</td>
507
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
508
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
509
+ <td><a href="https://data-structure-typed-docs.vercel.app/classes/MaxPriorityQueue.html"><span>MaxPriorityQueue</span></a></td>
510
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
511
+ </tr>
512
+ <tr>
513
+ <td>Min Priority Queue</td>
514
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
515
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
516
+ <td><a href="https://data-structure-typed-docs.vercel.app/classes/MinPriorityQueue.html"><span>MinPriorityQueue</span></a></td>
517
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
518
+ </tr>
519
+ <tr>
520
+ <td>Trie</td>
521
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
522
+ <td></td>
523
+ <td><a href="https://data-structure-typed-docs.vercel.app/classes/Trie.html"><span>Trie</span></a></td>
524
+ <td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
525
+ </tr>
526
+ </tbody>
527
+ </table>
528
+
529
+
530
+ # Why
531
+
532
+ ## Complexities
533
+
534
+ ### performance of Big O
535
+
536
+ <table>
537
+ <thead>
538
+ <tr>
539
+ <th>Big O Notation</th>
540
+ <th>Type</th>
541
+ <th>Computations for 10 elements</th>
542
+ <th>Computations for 100 elements</th>
543
+ <th>Computations for 1000 elements</th>
544
+ </tr>
545
+ </thead>
546
+ <tbody>
547
+ <tr>
548
+ <td><strong>O(1)</strong></td>
549
+ <td>Constant</td>
550
+ <td>1</td>
551
+ <td>1</td>
552
+ <td>1</td>
553
+ </tr>
554
+ <tr>
555
+ <td><strong>O(log N)</strong></td>
556
+ <td>Logarithmic</td>
557
+ <td>3</td>
558
+ <td>6</td>
559
+ <td>9</td>
560
+ </tr>
561
+ <tr>
562
+ <td><strong>O(N)</strong></td>
563
+ <td>Linear</td>
564
+ <td>10</td>
565
+ <td>100</td>
566
+ <td>1000</td>
567
+ </tr>
568
+ <tr>
569
+ <td><strong>O(N log N)</strong></td>
570
+ <td>n log(n)</td>
571
+ <td>30</td>
572
+ <td>600</td>
573
+ <td>9000</td>
574
+ </tr>
575
+ <tr>
576
+ <td><strong>O(N^2)</strong></td>
577
+ <td>Quadratic</td>
578
+ <td>100</td>
579
+ <td>10000</td>
580
+ <td>1000000</td>
581
+ </tr>
582
+ <tr>
583
+ <td><strong>O(2^N)</strong></td>
584
+ <td>Exponential</td>
585
+ <td>1024</td>
586
+ <td>1.26e+29</td>
587
+ <td>1.07e+301</td>
588
+ </tr>
589
+ <tr>
590
+ <td><strong>O(N!)</strong></td>
591
+ <td>Factorial</td>
592
+ <td>3628800</td>
593
+ <td>9.3e+157</td>
594
+ <td>4.02e+2567</td>
595
+ </tr>
596
+ </tbody>
597
+ </table>
598
+
599
+ ### Data Structure Complexity
600
+
601
+ <table>
602
+ <thead>
603
+ <tr>
604
+ <th>Data Structure</th>
605
+ <th>Access</th>
606
+ <th>Search</th>
607
+ <th>Insertion</th>
608
+ <th>Deletion</th>
609
+ <th>Comments</th>
610
+ </tr>
611
+ </thead>
612
+ <tbody>
613
+ <tr>
614
+ <td><strong>Array</strong></td>
615
+ <td>1</td>
616
+ <td>n</td>
617
+ <td>n</td>
618
+ <td>n</td>
619
+ <td></td>
620
+ </tr>
621
+ <tr>
622
+ <td><strong>Stack</strong></td>
623
+ <td>n</td>
624
+ <td>n</td>
625
+ <td>1</td>
626
+ <td>1</td>
627
+ <td></td>
628
+ </tr>
629
+ <tr>
630
+ <td><strong>Queue</strong></td>
631
+ <td>n</td>
632
+ <td>n</td>
633
+ <td>1</td>
634
+ <td>1</td>
635
+ <td></td>
636
+ </tr>
637
+ <tr>
638
+ <td><strong>Linked List</strong></td>
639
+ <td>n</td>
640
+ <td>n</td>
641
+ <td>1</td>
642
+ <td>n</td>
643
+ <td></td>
644
+ </tr>
645
+ <tr>
646
+ <td><strong>Hash Table</strong></td>
647
+ <td>-</td>
648
+ <td>n</td>
649
+ <td>n</td>
650
+ <td>n</td>
651
+ <td>In case of perfect hash function costs would be O(1)</td>
652
+ </tr>
653
+ <tr>
654
+ <td><strong>Binary Search Tree</strong></td>
655
+ <td>n</td>
656
+ <td>n</td>
657
+ <td>n</td>
658
+ <td>n</td>
659
+ <td>In case of balanced tree costs would be O(log(n))</td>
660
+ </tr>
661
+ <tr>
662
+ <td><strong>B-Tree</strong></td>
663
+ <td>log(n)</td>
664
+ <td>log(n)</td>
665
+ <td>log(n)</td>
666
+ <td>log(n)</td>
667
+ <td></td>
668
+ </tr>
669
+ <tr>
670
+ <td><strong>Red-Black Tree</strong></td>
671
+ <td>log(n)</td>
672
+ <td>log(n)</td>
673
+ <td>log(n)</td>
674
+ <td>log(n)</td>
675
+ <td></td>
676
+ </tr>
677
+ <tr>
678
+ <td><strong>AVL Tree</strong></td>
679
+ <td>log(n)</td>
680
+ <td>log(n)</td>
681
+ <td>log(n)</td>
682
+ <td>log(n)</td>
683
+ <td></td>
684
+ </tr>
685
+ <tr>
686
+ <td><strong>Bloom Filter</strong></td>
687
+ <td>-</td>
688
+ <td>1</td>
689
+ <td>1</td>
690
+ <td>-</td>
691
+ <td>False positives are possible while searching</td>
692
+ </tr>
693
+ </tbody>
694
+ </table>
695
+
696
+ ### Sorting Complexity
697
+
698
+ <table>
699
+ <thead>
700
+ <tr>
701
+ <th>Name</th>
702
+ <th>Best</th>
703
+ <th>Average</th>
704
+ <th>Worst</th>
705
+ <th>Memory</th>
706
+ <th>Stable</th>
707
+ <th>Comments</th>
708
+ </tr>
709
+ </thead>
710
+ <tbody>
711
+ <tr>
712
+ <td><strong>Bubble sort</strong></td>
713
+ <td>n</td>
714
+ <td>n<sup>2</sup></td>
715
+ <td>n<sup>2</sup></td>
716
+ <td>1</td>
717
+ <td>Yes</td>
718
+ <td></td>
719
+ </tr>
720
+ <tr>
721
+ <td><strong>Insertion sort</strong></td>
722
+ <td>n</td>
723
+ <td>n<sup>2</sup></td>
724
+ <td>n<sup>2</sup></td>
725
+ <td>1</td>
726
+ <td>Yes</td>
727
+ <td></td>
728
+ </tr>
729
+ <tr>
730
+ <td><strong>Selection sort</strong></td>
731
+ <td>n<sup>2</sup></td>
732
+ <td>n<sup>2</sup></td>
733
+ <td>n<sup>2</sup></td>
734
+ <td>1</td>
735
+ <td>No</td>
736
+ <td></td>
737
+ </tr>
738
+ <tr>
739
+ <td><strong>Heap sort</strong></td>
740
+ <td>n&nbsp;log(n)</td>
741
+ <td>n&nbsp;log(n)</td>
742
+ <td>n&nbsp;log(n)</td>
743
+ <td>1</td>
744
+ <td>No</td>
745
+ <td></td>
746
+ </tr>
747
+ <tr>
748
+ <td><strong>Merge sort</strong></td>
749
+ <td>n&nbsp;log(n)</td>
750
+ <td>n&nbsp;log(n)</td>
751
+ <td>n&nbsp;log(n)</td>
752
+ <td>n</td>
753
+ <td>Yes</td>
754
+ <td></td>
755
+ </tr>
756
+ <tr>
757
+ <td><strong>Quick sort</strong></td>
758
+ <td>n&nbsp;log(n)</td>
759
+ <td>n&nbsp;log(n)</td>
760
+ <td>n<sup>2</sup></td>
761
+ <td>log(n)</td>
762
+ <td>No</td>
763
+ <td>Quicksort is usually done in-place with O(log(n)) stack space</td>
764
+ </tr>
765
+ <tr>
766
+ <td><strong>Shell sort</strong></td>
767
+ <td>n&nbsp;log(n)</td>
768
+ <td>depends on gap sequence</td>
769
+ <td>n&nbsp;(log(n))<sup>2</sup></td>
770
+ <td>1</td>
771
+ <td>No</td>
772
+ <td></td>
773
+ </tr>
774
+ <tr>
775
+ <td><strong>Counting sort</strong></td>
776
+ <td>n + r</td>
777
+ <td>n + r</td>
778
+ <td>n + r</td>
779
+ <td>n + r</td>
780
+ <td>Yes</td>
781
+ <td>r - biggest number in array</td>
782
+ </tr>
783
+ <tr>
784
+ <td><strong>Radix sort</strong></td>
785
+ <td>n * k</td>
786
+ <td>n * k</td>
787
+ <td>n * k</td>
788
+ <td>n + k</td>
789
+ <td>Yes</td>
790
+ <td>k - length of longest key</td>
791
+ </tr>
792
+ </tbody>
793
+ </table>
794
+
795
+ ![overview diagram](https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/assets/overview-diagram-of-data-structures.png)
796
+
797
+ ![complexities](https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/assets/complexities-diff.jpg)
798
+
799
+ ![complexities of data structures](https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/assets/data-structure-complexities.jpg)
800
+
801
+
802
+
803
+
804
+
805
+