diff --git a/CHANGELOG.md b/CHANGELOG.md index fef9aee..b112baf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ All notable changes to this project will be documented in this file. - [Semantic Versioning](https://semver.org/spec/v2.0.0.html) - [`auto-changelog`](https://github.com/CookPete/auto-changelog) -## [v1.42.1](https://github.com/zrwusa/data-structure-typed/compare/v1.35.0...main) (upcoming) +## [v1.42.2](https://github.com/zrwusa/data-structure-typed/compare/v1.35.0...main) (upcoming) ### Changes diff --git a/README.md b/README.md index f26e3de..853d220 100644 --- a/README.md +++ b/README.md @@ -636,40 +636,40 @@ optimal approach to data structure design. [//]: # (Start of Replace Section)
avl-tree
-
test nametime taken (ms)executions per secsample deviation
10,000 add randomly30.7432.537.33e-4
10,000 add & delete randomly67.9914.710.00
10,000 addMany39.8225.114.59e-4
10,000 get26.7037.462.61e-4
+
test nametime taken (ms)executions per secsample deviation
10,000 add randomly31.9331.322.30e-4
10,000 add & delete randomly69.1214.470.00
10,000 addMany41.1424.311.60e-4
10,000 get28.6834.867.65e-4
binary-tree
-
test nametime taken (ms)executions per secsample deviation
1,000 add randomly12.9177.445.52e-4
1,000 add & delete randomly15.9062.881.24e-4
1,000 addMany10.7293.271.52e-4
1,000 get18.3954.392.28e-4
1,000 dfs71.5813.970.00
1,000 bfs57.6217.350.00
1,000 morris37.1726.902.13e-4
+
test nametime taken (ms)executions per secsample deviation
1,000 add randomly13.1276.213.40e-4
1,000 add & delete randomly16.3361.224.17e-4
1,000 addMany10.9691.223.99e-4
1,000 get18.6553.634.20e-4
1,000 dfs71.8213.920.00
1,000 bfs58.9516.960.00
1,000 morris37.4626.704.60e-4
bst
-
test nametime taken (ms)executions per secsample deviation
10,000 add randomly30.5032.790.00
10,000 add & delete randomly68.3514.638.92e-4
10,000 addMany29.4134.009.96e-4
10,000 get28.2735.375.46e-4
+
test nametime taken (ms)executions per secsample deviation
10,000 add randomly32.9830.320.00
10,000 add & delete randomly74.4713.430.00
10,000 addMany29.9333.416.02e-4
10,000 get29.9233.428.61e-4
rb-tree
-
test nametime taken (ms)executions per secsample deviation
100,000 add randomly82.1912.170.01
100,000 add & 1000 delete randomly99.7410.030.03
100,000 getNode78.2712.780.04
+
test nametime taken (ms)executions per secsample deviation
100,000 add randomly80.4912.420.01
100,000 add & 1000 delete randomly89.9711.110.01
100,000 getNode68.6314.570.01
directed-graph
-
test nametime taken (ms)executions per secsample deviation
1,000 addVertex0.109687.711.14e-5
1,000 addEdge7.42134.680.00
1,000 getVertex0.052.05e+49.33e-6
1,000 getEdge20.2949.290.00
tarjan190.485.250.01
tarjan all190.725.240.00
topologicalSort161.216.200.02
+
test nametime taken (ms)executions per secsample deviation
1,000 addVertex0.109878.721.87e-6
1,000 addEdge6.34157.782.53e-4
1,000 getVertex0.052.12e+41.05e-6
1,000 getEdge23.0843.330.00
tarjan217.754.590.01
tarjan all219.234.560.01
topologicalSort175.735.690.02
heap
-
test nametime taken (ms)executions per secsample deviation
10,000 add & pop4.70212.555.89e-4
10,000 fib add & pop366.962.730.02
+
test nametime taken (ms)executions per secsample deviation
10,000 add & pop4.64215.446.89e-5
10,000 fib add & pop357.372.800.01
doubly-linked-list
-
test nametime taken (ms)executions per secsample deviation
1,000,000 unshift226.424.420.04
1,000,000 unshift & shift163.146.130.01
1,000,000 insertBefore343.182.910.08
+
test nametime taken (ms)executions per secsample deviation
1,000,000 unshift239.344.180.04
1,000,000 unshift & shift168.745.930.04
1,000,000 insertBefore324.743.080.06
singly-linked-list
-
test nametime taken (ms)executions per secsample deviation
10,000 push & pop217.344.600.01
10,000 insertBefore248.514.020.00
+
test nametime taken (ms)executions per secsample deviation
10,000 push & pop213.864.680.01
10,000 insertBefore254.023.940.02
max-priority-queue
-
test nametime taken (ms)executions per secsample deviation
10,000 refill & poll11.6585.813.52e-4
+
test nametime taken (ms)executions per secsample deviation
10,000 refill & poll11.3987.762.14e-4
deque
-
test nametime taken (ms)executions per secsample deviation
1,000,000 push224.574.450.04
1,000,000 shift25.1539.770.00
+
test nametime taken (ms)executions per secsample deviation
1,000,000 push233.914.280.05
1,000,000 shift25.6139.050.00
queue
-
test nametime taken (ms)executions per secsample deviation
1,000,000 push43.5222.980.01
1,000,000 push & shift79.7112.550.00
+
test nametime taken (ms)executions per secsample deviation
1,000,000 push43.8822.790.01
1,000,000 push & shift81.7112.240.00
trie
-
test nametime taken (ms)executions per secsample deviation
100,000 push59.2816.870.00
100,000 getWords106.799.360.00
+
test nametime taken (ms)executions per secsample deviation
100,000 push59.9316.690.01
100,000 getWords93.1010.740.01
[//]: # (End of Replace Section) \ No newline at end of file diff --git a/package.json b/package.json index 4690f56..b47f4f6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "data-structure-typed", - "version": "1.42.1", + "version": "1.42.2", "description": "Data Structures of Javascript & TypeScript. Binary Tree, BST, Graph, Heap, Priority Queue, Linked List, Queue, Deque, Stack, AVL Tree, Tree Multiset, Trie, Directed Graph, Undirected Graph, Singly Linked List, Doubly Linked List, Max Heap, Max Priority Queue, Min Heap, Min Priority Queue.", "main": "dist/cjs/src/index.js", "module": "dist/mjs/src/index.js", diff --git a/test/unit/data-structures/binary-tree/bst.test.ts b/test/unit/data-structures/binary-tree/bst.test.ts index 0d9b295..9540831 100644 --- a/test/unit/data-structures/binary-tree/bst.test.ts +++ b/test/unit/data-structures/binary-tree/bst.test.ts @@ -837,4 +837,14 @@ describe('BST Performance test', function () { bst.addMany([9, 8, 7, 3, 1, 2, 5, 4, 6], undefined, false); expect(bst.lastKey()).toBe(9); }); + + + it('should subTreeTraverse, null should be ignored', () => { + const bst = new BST(); + bst.addMany([4, 2, 6, null, 1, 3, null, 5, null, 7]); + expect(bst.subTreeTraverse(node => node.key, bst.getNode(6), IterationType.ITERATIVE)).toEqual([6,5, 7]); + expect(bst.subTreeTraverse(node => node.key, bst.getNode(6), IterationType.RECURSIVE)).toEqual([6,5, 7]); + expect(bst.subTreeTraverse(node => node === null ? null : node.key, bst.getNode(6), IterationType.ITERATIVE, true)).toEqual([6, 5, 7]); + expect(bst.subTreeTraverse(node => node === null ? null : node.key, bst.getNode(6), IterationType.RECURSIVE, true)).toEqual([6, 5, 7]); + }); });