data-structure-typed 1.39.5 → 1.39.6

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 (107) hide show
  1. package/CHANGELOG.md +2 -1
  2. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +6 -6
  3. package/dist/cjs/data-structures/binary-tree/avl-tree.js +13 -13
  4. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  5. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +7 -7
  6. package/dist/cjs/data-structures/binary-tree/binary-tree.js +17 -17
  7. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  8. package/dist/cjs/data-structures/binary-tree/bst.d.ts +6 -6
  9. package/dist/cjs/data-structures/binary-tree/bst.js +13 -13
  10. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  11. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +2 -2
  12. package/dist/cjs/data-structures/binary-tree/rb-tree.js +4 -4
  13. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  14. package/dist/cjs/data-structures/binary-tree/segment-tree.d.ts +7 -7
  15. package/dist/cjs/data-structures/binary-tree/segment-tree.js +16 -16
  16. package/dist/cjs/data-structures/binary-tree/segment-tree.js.map +1 -1
  17. package/dist/cjs/data-structures/binary-tree/tree-multiset.d.ts +6 -6
  18. package/dist/cjs/data-structures/binary-tree/tree-multiset.js +18 -18
  19. package/dist/cjs/data-structures/binary-tree/tree-multiset.js.map +1 -1
  20. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +17 -17
  21. package/dist/cjs/data-structures/graph/abstract-graph.js +24 -24
  22. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  23. package/dist/cjs/data-structures/graph/directed-graph.d.ts +12 -12
  24. package/dist/cjs/data-structures/graph/directed-graph.js +15 -15
  25. package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
  26. package/dist/cjs/data-structures/graph/map-graph.d.ts +9 -9
  27. package/dist/cjs/data-structures/graph/map-graph.js +13 -13
  28. package/dist/cjs/data-structures/graph/map-graph.js.map +1 -1
  29. package/dist/cjs/data-structures/graph/undirected-graph.d.ts +11 -11
  30. package/dist/cjs/data-structures/graph/undirected-graph.js +14 -14
  31. package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
  32. package/dist/cjs/data-structures/hash/hash-table.d.ts +4 -4
  33. package/dist/cjs/data-structures/hash/hash-table.js +8 -8
  34. package/dist/cjs/data-structures/hash/hash-table.js.map +1 -1
  35. package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +31 -31
  36. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +54 -54
  37. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  38. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +24 -24
  39. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +52 -52
  40. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  41. package/dist/cjs/data-structures/queue/queue.js +1 -1
  42. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  43. package/dist/cjs/interfaces/binary-tree.d.ts +2 -2
  44. package/dist/cjs/interfaces/graph.d.ts +2 -2
  45. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +6 -6
  46. package/dist/mjs/data-structures/binary-tree/avl-tree.js +13 -13
  47. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +7 -7
  48. package/dist/mjs/data-structures/binary-tree/binary-tree.js +18 -18
  49. package/dist/mjs/data-structures/binary-tree/bst.d.ts +6 -6
  50. package/dist/mjs/data-structures/binary-tree/bst.js +13 -13
  51. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +2 -2
  52. package/dist/mjs/data-structures/binary-tree/rb-tree.js +4 -4
  53. package/dist/mjs/data-structures/binary-tree/segment-tree.d.ts +7 -7
  54. package/dist/mjs/data-structures/binary-tree/segment-tree.js +16 -16
  55. package/dist/mjs/data-structures/binary-tree/tree-multiset.d.ts +6 -6
  56. package/dist/mjs/data-structures/binary-tree/tree-multiset.js +18 -18
  57. package/dist/mjs/data-structures/graph/abstract-graph.d.ts +17 -17
  58. package/dist/mjs/data-structures/graph/abstract-graph.js +26 -26
  59. package/dist/mjs/data-structures/graph/directed-graph.d.ts +12 -12
  60. package/dist/mjs/data-structures/graph/directed-graph.js +15 -15
  61. package/dist/mjs/data-structures/graph/map-graph.d.ts +9 -9
  62. package/dist/mjs/data-structures/graph/map-graph.js +13 -13
  63. package/dist/mjs/data-structures/graph/undirected-graph.d.ts +11 -11
  64. package/dist/mjs/data-structures/graph/undirected-graph.js +14 -14
  65. package/dist/mjs/data-structures/hash/hash-table.d.ts +4 -4
  66. package/dist/mjs/data-structures/hash/hash-table.js +9 -9
  67. package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +31 -31
  68. package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +55 -55
  69. package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +24 -24
  70. package/dist/mjs/data-structures/linked-list/singly-linked-list.js +53 -53
  71. package/dist/mjs/data-structures/queue/queue.js +1 -1
  72. package/dist/mjs/interfaces/binary-tree.d.ts +2 -2
  73. package/dist/mjs/interfaces/graph.d.ts +2 -2
  74. package/dist/umd/data-structure-typed.min.js +1 -1
  75. package/dist/umd/data-structure-typed.min.js.map +1 -1
  76. package/package.json +5 -5
  77. package/src/data-structures/binary-tree/avl-tree.ts +13 -13
  78. package/src/data-structures/binary-tree/binary-tree.ts +18 -18
  79. package/src/data-structures/binary-tree/bst.ts +16 -16
  80. package/src/data-structures/binary-tree/rb-tree.ts +6 -6
  81. package/src/data-structures/binary-tree/segment-tree.ts +15 -15
  82. package/src/data-structures/binary-tree/tree-multiset.ts +18 -18
  83. package/src/data-structures/graph/abstract-graph.ts +34 -34
  84. package/src/data-structures/graph/directed-graph.ts +16 -16
  85. package/src/data-structures/graph/map-graph.ts +13 -13
  86. package/src/data-structures/graph/undirected-graph.ts +15 -15
  87. package/src/data-structures/hash/hash-table.ts +9 -9
  88. package/src/data-structures/linked-list/doubly-linked-list.ts +61 -61
  89. package/src/data-structures/linked-list/singly-linked-list.ts +58 -58
  90. package/src/data-structures/queue/queue.ts +1 -1
  91. package/src/interfaces/binary-tree.ts +2 -2
  92. package/src/interfaces/graph.ts +2 -2
  93. package/test/integration/bst.test.ts +2 -2
  94. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +2 -2
  95. package/test/unit/data-structures/binary-tree/binary-index-tree.test.ts +3 -3
  96. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +8 -8
  97. package/test/unit/data-structures/binary-tree/bst.test.ts +4 -4
  98. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +3 -3
  99. package/test/unit/data-structures/binary-tree/tree-multiset.test.ts +2 -2
  100. package/test/unit/data-structures/graph/abstract-graph.test.ts +99 -2
  101. package/test/unit/data-structures/graph/directed-graph.test.ts +22 -12
  102. package/test/unit/data-structures/graph/undirected-graph.test.ts +8 -0
  103. package/test/unit/data-structures/hash/hash-table.test.ts +1 -1
  104. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +30 -30
  105. package/test/unit/data-structures/linked-list/linked-list.test.ts +1 -1
  106. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +15 -15
  107. package/test/utils/big-o.ts +7 -7
@@ -93,9 +93,9 @@ describe('DirectedGraph Operation Test', () => {
93
93
  });
94
94
 
95
95
  class MyVertex<V = any> extends DirectedVertex<V> {
96
- constructor(key: VertexKey, val?: V) {
97
- super(key, val);
98
- this._data = val;
96
+ constructor(key: VertexKey, value?: V) {
97
+ super(key, value);
98
+ this._data = value;
99
99
  }
100
100
 
101
101
  private _data: V | undefined;
@@ -110,9 +110,9 @@ class MyVertex<V = any> extends DirectedVertex<V> {
110
110
  }
111
111
 
112
112
  class MyEdge<E = any> extends DirectedEdge<E> {
113
- constructor(v1: VertexKey, v2: VertexKey, weight?: number, val?: E) {
114
- super(v1, v2, weight, val);
115
- this._data = val;
113
+ constructor(v1: VertexKey, v2: VertexKey, weight?: number, value?: E) {
114
+ super(v1, v2, weight, value);
115
+ this._data = value;
116
116
  }
117
117
 
118
118
  private _data: E | undefined;
@@ -132,12 +132,20 @@ class MyDirectedGraph<
132
132
  VO extends MyVertex<V> = MyVertex<V>,
133
133
  EO extends MyEdge<E> = MyEdge<E>
134
134
  > extends DirectedGraph<V, E, VO, EO> {
135
- createVertex(key: VertexKey, val: V): VO {
136
- return new MyVertex(key, val) as VO;
135
+ createVertex(key: VertexKey, value: V): VO {
136
+ return new MyVertex(key, value) as VO;
137
+ }
138
+
139
+ createEdge(src: VertexKey, dest: VertexKey, weight?: number, value?: E): EO {
140
+ return new MyEdge(src, dest, weight ?? 1, value) as EO;
141
+ }
142
+
143
+ setInEdgeMap(value: Map<VO, EO[]>) {
144
+ super._setInEdgeMap(value);
137
145
  }
138
146
 
139
- createEdge(src: VertexKey, dest: VertexKey, weight?: number, val?: E): EO {
140
- return new MyEdge(src, dest, weight ?? 1, val) as EO;
147
+ setOutEdgeMap(value: Map<VO, EO[]>) {
148
+ super._setOutEdgeMap(value);
141
149
  }
142
150
  }
143
151
 
@@ -164,6 +172,8 @@ describe('Inherit from DirectedGraph and perform operations', () => {
164
172
  myGraph.addVertex(2, 'data2');
165
173
  myGraph.addEdge(1, 2, 10, 'edge-data1-2');
166
174
  myGraph.addEdge(new MyEdge(2, 1, 20, 'edge-data2-1'));
175
+ myGraph.setInEdgeMap(myGraph.inEdgeMap);
176
+ myGraph.setOutEdgeMap(myGraph.outEdgeMap);
167
177
 
168
178
  expect(myGraph.edgeSet().length).toBe(2);
169
179
  // TODO
@@ -182,7 +192,7 @@ describe('Inherit from DirectedGraph and perform operations', () => {
182
192
  expect(edge1).toBeInstanceOf(MyEdge);
183
193
  if (edge1) {
184
194
  expect(edge1.data).toBe('val1');
185
- expect(edge1?.val).toBe('val1');
195
+ expect(edge1?.value).toBe('val1');
186
196
  expect(edge1).toBeInstanceOf(MyEdge);
187
197
  expect(edge1.src).toBe(1);
188
198
  expect(edge1).toEqual(edge2);
@@ -204,7 +214,7 @@ describe('Inherit from DirectedGraph and perform operations', () => {
204
214
 
205
215
  expect(removedEdge).toBeInstanceOf(MyEdge);
206
216
  if (removedEdge) {
207
- removedEdge && expect(removedEdge.val).toBe('edge-data1-2');
217
+ removedEdge && expect(removedEdge.value).toBe('edge-data1-2');
208
218
  removedEdge && expect(removedEdge.src).toBe(1);
209
219
  }
210
220
  expect(edgeAfterRemoval).toBeNull();
@@ -7,6 +7,14 @@ describe('UndirectedGraph Operation Test', () => {
7
7
  graph = new UndirectedGraph();
8
8
  });
9
9
 
10
+ it('should edge cases', () => {
11
+ expect(graph.deleteEdge(new UndirectedEdge('c', 'd'))).toBe(null);
12
+ expect(graph.deleteEdgeBetween('c', 'd')).toBe(null);
13
+ expect(graph.degreeOf('c')).toBe(0);
14
+ expect(graph.edgesOf('c').length).toBe(0);
15
+ expect(graph.getEndsOfEdge(new UndirectedEdge('c', 'd'))).toBe(null);
16
+ });
17
+
10
18
  it('should add vertices', () => {
11
19
  const vertex1 = new UndirectedVertex('A');
12
20
  const vertex2 = new UndirectedVertex('B');
@@ -7,7 +7,7 @@ describe('HashNode', () => {
7
7
  const hashNode = new HashTableNode(key, value);
8
8
 
9
9
  expect(hashNode.key).toBe(key);
10
- expect(hashNode.val).toBe(value);
10
+ expect(hashNode.value).toBe(value);
11
11
  expect(hashNode.next).toBe(null);
12
12
  });
13
13
  });
@@ -4,9 +4,9 @@ import {bigO, magnitude} from '../../../utils';
4
4
  describe('DoublyLinkedListNode', () => {
5
5
  it('should DoublyLinkedListNode', () => {
6
6
  const node1 = new DoublyLinkedListNode<number>(2);
7
- expect(node1.val).toBe(2);
8
- node1.val = 1;
9
- expect(node1.val).toBe(1);
7
+ expect(node1.value).toBe(2);
8
+ node1.value = 1;
9
+ expect(node1.value).toBe(1);
10
10
  });
11
11
  });
12
12
 
@@ -33,13 +33,13 @@ describe('DoublyLinkedList Operation Test', () => {
33
33
 
34
34
  it('should delete tail', () => {
35
35
  expect(list.delete(list.tail)).toBe(true);
36
- expect(list.tail?.val).toBe(4);
36
+ expect(list.tail?.value).toBe(4);
37
37
  expect(list.delete(6)).toBe(false);
38
- expect(list.tail?.val).toBe(4);
38
+ expect(list.tail?.value).toBe(4);
39
39
  });
40
40
 
41
41
  it('should find null', () => {
42
- expect(list.find(val => val === 6)).toBe(null);
42
+ expect(list.find(value => value === 6)).toBe(null);
43
43
  });
44
44
 
45
45
  it('should indexOf -1', () => {
@@ -47,7 +47,7 @@ describe('DoublyLinkedList Operation Test', () => {
47
47
  });
48
48
 
49
49
  it('should findBackward null', () => {
50
- expect(list.findBackward(val => val === 0)).toBe(null);
50
+ expect(list.findBackward(value => value === 0)).toBe(null);
51
51
  });
52
52
 
53
53
  it('should insertAfter tail', () => {
@@ -80,8 +80,8 @@ describe('DoublyLinkedList Operation Test', () => {
80
80
  list.push(2);
81
81
  list.push(3);
82
82
  expect(list.length).toBe(3);
83
- expect(list.head!.val).toBe(1);
84
- expect(list.tail!.val).toBe(3);
83
+ expect(list.head!.value).toBe(1);
84
+ expect(list.tail!.value).toBe(3);
85
85
  });
86
86
 
87
87
  it('should pop elements from the end of the list', () => {
@@ -90,8 +90,8 @@ describe('DoublyLinkedList Operation Test', () => {
90
90
  const poppedValue = list.pop();
91
91
  expect(poppedValue).toBe(2);
92
92
  expect(list.length).toBe(1);
93
- expect(list.head!.val).toBe(1);
94
- expect(list.tail!.val).toBe(1);
93
+ expect(list.head!.value).toBe(1);
94
+ expect(list.tail!.value).toBe(1);
95
95
  });
96
96
  it('should insert elements at specific positions', () => {
97
97
  list.push(1);
@@ -114,7 +114,7 @@ describe('DoublyLinkedList Operation Test', () => {
114
114
  list.insertAt(5, 4);
115
115
  expect(list.length).toBe(6);
116
116
  expect(list.getAt(5)).toBe(4);
117
- expect(list.tail!.val).toBe(4);
117
+ expect(list.tail!.value).toBe(4);
118
118
  });
119
119
 
120
120
  it('should delete elements at specific positions', () => {
@@ -126,12 +126,12 @@ describe('DoublyLinkedList Operation Test', () => {
126
126
  const deletedValue = list.deleteAt(0);
127
127
  expect(deletedValue).toBe(1);
128
128
  expect(list.length).toBe(2);
129
- expect(list.head!.val).toBe(2);
129
+ expect(list.head!.value).toBe(2);
130
130
 
131
131
  // Deleting from the middle
132
132
  list.deleteAt(0); // Deleting the second element
133
133
  expect(list.length).toBe(1);
134
- expect(list.head!.val).toBe(3);
134
+ expect(list.head!.value).toBe(3);
135
135
 
136
136
  // Deleting from the end
137
137
  list.deleteAt(0);
@@ -147,12 +147,12 @@ describe('DoublyLinkedList Operation Test', () => {
147
147
 
148
148
  list.delete(2);
149
149
  expect(list.length).toBe(2);
150
- expect(list.head!.val).toBe(1);
151
- expect(list.tail!.val).toBe(3);
150
+ expect(list.head!.value).toBe(1);
151
+ expect(list.tail!.value).toBe(3);
152
152
 
153
153
  list.delete(1);
154
154
  expect(list.length).toBe(1);
155
- expect(list.head!.val).toBe(3);
155
+ expect(list.head!.value).toBe(3);
156
156
 
157
157
  list.delete(3);
158
158
  expect(list.length).toBe(0);
@@ -176,7 +176,7 @@ describe('DoublyLinkedList Operation Test', () => {
176
176
  list.push(2);
177
177
  list.push(3);
178
178
 
179
- const mappedList = list.map(val => val * 2);
179
+ const mappedList = list.map(value => value * 2);
180
180
 
181
181
  expect(mappedList.toArray()).toEqual([2, 4, 6]);
182
182
  });
@@ -187,7 +187,7 @@ describe('DoublyLinkedList Operation Test', () => {
187
187
  list.push(3);
188
188
  list.push(4);
189
189
 
190
- const filteredList = list.filter(val => val % 2 === 0);
190
+ const filteredList = list.filter(value => value % 2 === 0);
191
191
 
192
192
  expect(filteredList.toArray()).toEqual([2, 4]);
193
193
  });
@@ -198,7 +198,7 @@ describe('DoublyLinkedList Operation Test', () => {
198
198
  list.push(3);
199
199
  list.push(4);
200
200
 
201
- const sum = list.reduce((acc, val) => acc + val, 0);
201
+ const sum = list.reduce((acc, value) => acc + value, 0);
202
202
 
203
203
  expect(sum).toBe(10);
204
204
  });
@@ -227,7 +227,7 @@ describe('DoublyLinkedList Operation Test', () => {
227
227
  list.push(2);
228
228
  list.push(3);
229
229
 
230
- const found = list.find(val => val % 2 === 0);
230
+ const found = list.find(value => value % 2 === 0);
231
231
 
232
232
  expect(found).toBe(2);
233
233
  });
@@ -248,7 +248,7 @@ describe('DoublyLinkedList Operation Test', () => {
248
248
  list.push(3);
249
249
  list.push(4);
250
250
 
251
- const lastEven = list.findBackward(val => val % 2 === 0);
251
+ const lastEven = list.findBackward(value => value % 2 === 0);
252
252
 
253
253
  expect(lastEven).toBe(4);
254
254
  });
@@ -283,8 +283,8 @@ describe('DoublyLinkedList Operation Test', () => {
283
283
  list.reverse();
284
284
 
285
285
  expect(list.toArray()).toEqual([3, 2, 1]);
286
- expect(list.head?.val).toBe(3);
287
- expect(list.tail?.val).toBe(1);
286
+ expect(list.head?.value).toBe(3);
287
+ expect(list.tail?.value).toBe(1);
288
288
  });
289
289
 
290
290
  it('should iterate over each element and apply a callback', () => {
@@ -293,8 +293,8 @@ describe('DoublyLinkedList Operation Test', () => {
293
293
  list.push(3);
294
294
 
295
295
  const result: number[] = [];
296
- list.forEach(val => {
297
- result.push(val * 2);
296
+ list.forEach(value => {
297
+ result.push(value * 2);
298
298
  });
299
299
 
300
300
  expect(result).toEqual([2, 4, 6]);
@@ -305,7 +305,7 @@ describe('DoublyLinkedList Operation Test', () => {
305
305
  list.push(2);
306
306
  list.push(3);
307
307
 
308
- const mappedList = list.map(val => val * 2);
308
+ const mappedList = list.map(value => value * 2);
309
309
 
310
310
  expect(mappedList.toArray()).toEqual([2, 4, 6]);
311
311
  });
@@ -316,7 +316,7 @@ describe('DoublyLinkedList Operation Test', () => {
316
316
  list.push(3);
317
317
  list.push(4);
318
318
 
319
- const filteredList = list.filter(val => val % 2 === 0);
319
+ const filteredList = list.filter(value => value % 2 === 0);
320
320
 
321
321
  expect(filteredList.toArray()).toEqual([2, 4]);
322
322
  });
@@ -326,7 +326,7 @@ describe('DoublyLinkedList Operation Test', () => {
326
326
  list.push(2);
327
327
  list.push(3);
328
328
 
329
- const sum = list.reduce((acc, val) => acc + val, 0);
329
+ const sum = list.reduce((acc, value) => acc + value, 0);
330
330
 
331
331
  expect(sum).toBe(6);
332
332
  });
@@ -387,7 +387,7 @@ describe('DoublyLinkedList Operation Test', () => {
387
387
  expect(insertSuccess).toBe(true);
388
388
 
389
389
  const getNode = objectList.getNode(newObj); // Use newObj instead of obj2
390
- expect(getNode?.val).toEqual(newObj);
390
+ expect(getNode?.value).toEqual(newObj);
391
391
 
392
392
  const deleted = objectList.delete(newObj); // Use newObj instead of obj2
393
393
  expect(deleted).toBe(true);
@@ -26,7 +26,7 @@ describe('LinkedList Performance Test', () => {
26
26
  if (i === midIndex) {
27
27
  midSinglyNode = singlyList.getNode(i);
28
28
  } else if (i > midIndex && midSinglyNode) {
29
- singlyList.insertBefore(midSinglyNode.val, i);
29
+ singlyList.insertBefore(midSinglyNode.value, i);
30
30
  }
31
31
  }
32
32
 
@@ -4,9 +4,9 @@ import {bigO, magnitude} from '../../../utils';
4
4
  describe('SinglyLinkedListNode', () => {
5
5
  it('should SinglyLinkedList', () => {
6
6
  const node1 = new SinglyLinkedListNode<number>(2);
7
- expect(node1.val).toBe(2);
8
- node1.val = 1;
9
- expect(node1.val).toBe(1);
7
+ expect(node1.value).toBe(2);
8
+ node1.value = 1;
9
+ expect(node1.value).toBe(1);
10
10
  });
11
11
  });
12
12
 
@@ -75,7 +75,7 @@ describe('SinglyLinkedList Operation Test', () => {
75
75
  list.push(3);
76
76
  const element = list.getAt(1);
77
77
  expect(element).toBe(2);
78
- expect(list.getNodeAt(2)?.val).toBe(3);
78
+ expect(list.getNodeAt(2)?.value).toBe(3);
79
79
  });
80
80
 
81
81
  it('should return undefined for an out-of-bounds index', () => {
@@ -382,7 +382,7 @@ describe('SinglyLinkedList Operation Test', () => {
382
382
  expect(insertSuccess).toBe(true);
383
383
 
384
384
  const getNode = objectList.getNode(newObj); // Use newObj instead of obj2
385
- expect(getNode?.val).toEqual(newObj);
385
+ expect(getNode?.value).toEqual(newObj);
386
386
 
387
387
  const deleted = objectList.delete(newObj); // Use newObj instead of obj2
388
388
  expect(deleted).toBe(true);
@@ -431,8 +431,8 @@ describe('SinglyLinkedList', () => {
431
431
  it('should push elements to the end of the list', () => {
432
432
  list.push(1);
433
433
  list.push(2);
434
- expect(list.head!.val).toBe(1);
435
- expect(list.tail!.val).toBe(2);
434
+ expect(list.head!.value).toBe(1);
435
+ expect(list.tail!.value).toBe(2);
436
436
  expect(list.length).toBe(2);
437
437
  });
438
438
 
@@ -441,8 +441,8 @@ describe('SinglyLinkedList', () => {
441
441
  list.push(2);
442
442
  const popped = list.pop();
443
443
  expect(popped).toBe(2);
444
- expect(list.head!.val).toBe(1);
445
- expect(list.tail!.val).toBe(1);
444
+ expect(list.head!.value).toBe(1);
445
+ expect(list.tail!.value).toBe(1);
446
446
  expect(list.length).toBe(1);
447
447
  });
448
448
 
@@ -451,8 +451,8 @@ describe('SinglyLinkedList', () => {
451
451
  list.push(2);
452
452
  list.push(3);
453
453
  list.reverse();
454
- expect(list.head!.val).toBe(3);
455
- expect(list.tail!.val).toBe(1);
454
+ expect(list.head!.value).toBe(3);
455
+ expect(list.tail!.value).toBe(1);
456
456
  // Add more assertions for reversed order.
457
457
  });
458
458
 
@@ -470,14 +470,14 @@ describe('SinglyLinkedList', () => {
470
470
  list.push(1);
471
471
  list.push(2);
472
472
  list.push(3);
473
- expect(list.filter(val => val !== 2).toArray()).toEqual([1, 3]);
473
+ expect(list.filter(value => value !== 2).toArray()).toEqual([1, 3]);
474
474
  });
475
475
 
476
476
  it('should forEach the list', () => {
477
477
  list.push(1);
478
478
  list.push(2);
479
479
  list.push(3);
480
- list.forEach(val => val++);
480
+ list.forEach(value => value++);
481
481
  expect(list.toArray()).toEqual([1, 2, 3]);
482
482
  });
483
483
 
@@ -485,11 +485,11 @@ describe('SinglyLinkedList', () => {
485
485
  list.addLast(1);
486
486
  list.push(2);
487
487
  list.push(3);
488
- expect(list.map(val => val * 2).toArray()).toEqual([2, 4, 6]);
488
+ expect(list.map(value => value * 2).toArray()).toEqual([2, 4, 6]);
489
489
  });
490
490
 
491
491
  it('should reduce the list', () => {
492
492
  const list1 = SinglyLinkedList.fromArray([1, 2, 3]);
493
- expect(list1.reduce((acc, val) => acc + val, 0)).toEqual(6);
493
+ expect(list1.reduce((acc, value) => acc + value, 0)).toEqual(6);
494
494
  });
495
495
  });
@@ -59,19 +59,19 @@ function findPotentialN(input: any): number {
59
59
  function linearRegression(x: number[], y: number[]) {
60
60
  const n = x.length;
61
61
 
62
- const sumX = x.reduce((acc, val) => acc + val, 0);
63
- const sumY = y.reduce((acc, val) => acc + val, 0);
62
+ const sumX = x.reduce((acc, value) => acc + value, 0);
63
+ const sumY = y.reduce((acc, value) => acc + value, 0);
64
64
 
65
- const sumXSquared = x.reduce((acc, val) => acc + val ** 2, 0);
66
- const sumXY = x.reduce((acc, val, i) => acc + val * y[i], 0);
65
+ const sumXSquared = x.reduce((acc, value) => acc + value ** 2, 0);
66
+ const sumXY = x.reduce((acc, value, i) => acc + value * y[i], 0);
67
67
 
68
68
  const slope = (n * sumXY - sumX * sumY) / (n * sumXSquared - sumX ** 2);
69
69
  const intercept = (sumY - slope * sumX) / n;
70
70
 
71
- const yHat = x.map(val => slope * val + intercept);
71
+ const yHat = x.map(value => slope * value + intercept);
72
72
 
73
- const totalVariation = y.map((val, i) => (val - yHat[i]) ** 2).reduce((acc, val) => acc + val, 0);
74
- const explainedVariation = y.map(val => (val - sumY / n) ** 2).reduce((acc, val) => acc + val, 0);
73
+ const totalVariation = y.map((value, i) => (value - yHat[i]) ** 2).reduce((acc, value) => acc + value, 0);
74
+ const explainedVariation = y.map(value => (value - sumY / n) ** 2).reduce((acc, value) => acc + value, 0);
75
75
 
76
76
  const rSquared = 1 - totalVariation / explainedVariation;
77
77