@raikuxq/alg-ds 1.1.2 → 1.1.5

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 (257) hide show
  1. package/README.md +26 -2
  2. package/lib/algorithms/binary-search.d.ts +5 -0
  3. package/lib/algorithms/binary-search.js +27 -0
  4. package/lib/algorithms/factorial.d.ts +9 -0
  5. package/lib/algorithms/factorial.js +17 -0
  6. package/lib/algorithms/fibonacci.d.ts +9 -0
  7. package/lib/algorithms/fibonacci.js +17 -0
  8. package/lib/algorithms/memoize.d.ts +5 -0
  9. package/lib/algorithms/memoize.js +22 -0
  10. package/lib/algorithms/sorts/bubble-sort.d.ts +9 -0
  11. package/lib/algorithms/sorts/bubble-sort.js +23 -0
  12. package/lib/algorithms/sorts/insertion-sort.d.ts +9 -0
  13. package/lib/algorithms/sorts/insertion-sort.js +25 -0
  14. package/lib/algorithms/sorts/merge-sort.d.ts +9 -0
  15. package/lib/algorithms/sorts/merge-sort.js +61 -0
  16. package/lib/algorithms/sorts/quick-sort.d.ts +9 -0
  17. package/lib/algorithms/sorts/quick-sort.js +45 -0
  18. package/lib/algorithms/sorts/select-sort.d.ts +9 -0
  19. package/lib/algorithms/sorts/select-sort.js +20 -0
  20. package/lib/algorithms/transpose-matrix.d.ts +5 -0
  21. package/lib/algorithms/transpose-matrix.js +20 -0
  22. package/lib/constants.d.ts +2 -0
  23. package/lib/constants.js +6 -0
  24. package/lib/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryNode.d.ts +15 -0
  25. package/lib/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryNode.js +53 -0
  26. package/lib/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.d.ts +60 -0
  27. package/lib/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.js +36 -0
  28. package/lib/data-structures/BinaryTree/BinarySearchTree/BinarySearchNode.d.ts +13 -0
  29. package/lib/data-structures/BinaryTree/BinarySearchTree/BinarySearchNode.js +59 -0
  30. package/lib/data-structures/BinaryTree/BinarySearchTree/BinarySearchTree.d.ts +70 -0
  31. package/lib/data-structures/BinaryTree/BinarySearchTree/BinarySearchTree.js +268 -0
  32. package/lib/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchNode.d.ts +16 -0
  33. package/lib/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchNode.js +70 -0
  34. package/lib/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchTree.d.ts +57 -0
  35. package/lib/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchTree.js +234 -0
  36. package/lib/data-structures/Graph/AbstractGraph.d.ts +84 -0
  37. package/lib/data-structures/Graph/AbstractGraph.js +141 -0
  38. package/lib/data-structures/Graph/DirectedGraph.d.ts +24 -0
  39. package/lib/data-structures/Graph/DirectedGraph.js +85 -0
  40. package/lib/data-structures/Graph/GraphEdge.d.ts +16 -0
  41. package/lib/data-structures/Graph/GraphEdge.js +43 -0
  42. package/lib/data-structures/Graph/UndirectedGraph.d.ts +28 -0
  43. package/lib/data-structures/Graph/UndirectedGraph.js +102 -0
  44. package/lib/data-structures/Graph/demo/generateRandomGraph.d.ts +4 -0
  45. package/lib/data-structures/Graph/demo/generateRandomGraph.js +72 -0
  46. package/lib/data-structures/Graph/iterator/AbstractGraphIterator.d.ts +35 -0
  47. package/lib/data-structures/Graph/iterator/AbstractGraphIterator.js +90 -0
  48. package/lib/data-structures/Graph/iterator/GraphIteratorBFS.d.ts +28 -0
  49. package/lib/data-structures/Graph/iterator/GraphIteratorBFS.js +70 -0
  50. package/lib/data-structures/Graph/iterator/GraphIteratorDFS.d.ts +28 -0
  51. package/lib/data-structures/Graph/iterator/GraphIteratorDFS.js +70 -0
  52. package/lib/data-structures/Graph/iterator/GraphIteratorDijkstra.d.ts +32 -0
  53. package/lib/data-structures/Graph/iterator/GraphIteratorDijkstra.js +99 -0
  54. package/lib/data-structures/Graph/presenter/presenterAdjacencyLists.d.ts +19 -0
  55. package/lib/data-structures/Graph/presenter/presenterAdjacencyLists.js +28 -0
  56. package/{src/data-structures/Graph/presenter/presenterAdjacencyMatrix.ts → lib/data-structures/Graph/presenter/presenterAdjacencyMatrix.d.ts} +32 -51
  57. package/lib/data-structures/Graph/presenter/presenterAdjacencyMatrix.js +48 -0
  58. package/lib/data-structures/Graph/searching/hasPath.d.ts +9 -0
  59. package/lib/data-structures/Graph/searching/hasPath.js +29 -0
  60. package/lib/data-structures/Graph/searching/shortestPath.d.ts +9 -0
  61. package/lib/data-structures/Graph/searching/shortestPath.js +29 -0
  62. package/lib/data-structures/Graph/strategy/BFSIterationStrategy.d.ts +6 -0
  63. package/lib/data-structures/Graph/strategy/BFSIterationStrategy.js +13 -0
  64. package/lib/data-structures/Graph/strategy/DFSIterationStrategy.d.ts +6 -0
  65. package/lib/data-structures/Graph/strategy/DFSIterationStrategy.js +13 -0
  66. package/lib/data-structures/Graph/strategy/DijkstraIterationStrategy.d.ts +6 -0
  67. package/lib/data-structures/Graph/strategy/DijkstraIterationStrategy.js +13 -0
  68. package/lib/data-structures/Graph/transposing/transposeDirectedGraph.d.ts +2 -0
  69. package/lib/data-structures/Graph/transposing/transposeDirectedGraph.js +14 -0
  70. package/lib/data-structures/HashTable/HashTable.d.ts +73 -0
  71. package/lib/data-structures/HashTable/HashTable.js +169 -0
  72. package/lib/data-structures/HashTable/HashTableNode.d.ts +11 -0
  73. package/lib/data-structures/HashTable/HashTableNode.js +39 -0
  74. package/lib/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedList.d.ts +125 -0
  75. package/lib/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedList.js +236 -0
  76. package/lib/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedNode.d.ts +20 -0
  77. package/lib/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedNode.js +41 -0
  78. package/lib/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedList.d.ts +48 -0
  79. package/lib/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedList.js +150 -0
  80. package/lib/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedNode.d.ts +25 -0
  81. package/lib/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedNode.js +65 -0
  82. package/lib/data-structures/LinkedList/SingleLinkedList/SingleLinkedList.d.ts +52 -0
  83. package/lib/data-structures/LinkedList/SingleLinkedList/SingleLinkedList.js +137 -0
  84. package/{src/data-structures/LinkedList/SingleLinkedList/SingleLinkedNode.ts → lib/data-structures/LinkedList/SingleLinkedList/SingleLinkedNode.d.ts} +7 -10
  85. package/lib/data-structures/LinkedList/SingleLinkedList/SingleLinkedNode.js +29 -0
  86. package/lib/data-structures/LoopedArray/LoopedArray.d.ts +86 -0
  87. package/lib/data-structures/LoopedArray/LoopedArray.js +161 -0
  88. package/lib/data-structures/Queue/Queue.d.ts +50 -0
  89. package/lib/data-structures/Queue/Queue.js +83 -0
  90. package/lib/data-structures/Stack/Stack.d.ts +50 -0
  91. package/lib/data-structures/Stack/Stack.js +83 -0
  92. package/lib/exports/algorithms.d.ts +16 -0
  93. package/lib/exports/algorithms.js +36 -0
  94. package/lib/exports/constants.d.ts +2 -0
  95. package/lib/exports/constants.js +7 -0
  96. package/lib/exports/data-structures.d.ts +11 -0
  97. package/lib/exports/data-structures.js +24 -0
  98. package/lib/exports/helpers.d.ts +6 -0
  99. package/lib/exports/helpers.js +14 -0
  100. package/lib/exports/sorts.d.ts +6 -0
  101. package/lib/exports/sorts.js +14 -0
  102. package/lib/exports/utils.d.ts +3 -0
  103. package/lib/exports/utils.js +14 -0
  104. package/lib/exports.d.ts +44 -0
  105. package/lib/exports.js +89 -0
  106. package/lib/helpers/createBinaryTree.d.ts +6 -0
  107. package/lib/helpers/createBinaryTree.js +22 -0
  108. package/lib/helpers/createGraph.d.ts +6 -0
  109. package/lib/helpers/createGraph.js +24 -0
  110. package/lib/helpers/createGraphFromMatrix.d.ts +7 -0
  111. package/lib/helpers/createGraphFromMatrix.js +37 -0
  112. package/lib/helpers/createLinkedList.d.ts +3 -0
  113. package/lib/helpers/createLinkedList.js +21 -0
  114. package/lib/index.d.ts +3 -0
  115. package/lib/index.js +6 -0
  116. package/lib/types/ArrayMatrix.d.ts +1 -0
  117. package/lib/types/ArrayMatrix.js +3 -0
  118. package/lib/types/EnumBinarySearchTreeType.d.ts +4 -0
  119. package/lib/types/EnumBinarySearchTreeType.js +9 -0
  120. package/lib/types/EnumGraphType.d.ts +4 -0
  121. package/lib/types/EnumGraphType.js +9 -0
  122. package/lib/types/EnumLinkedListType.d.ts +4 -0
  123. package/lib/types/EnumLinkedListType.js +9 -0
  124. package/lib/types/EnumRandomGenerationFormat.d.ts +4 -0
  125. package/lib/types/EnumRandomGenerationFormat.js +9 -0
  126. package/lib/types/EnumTreeTraversalType.d.ts +5 -0
  127. package/lib/types/EnumTreeTraversalType.js +10 -0
  128. package/lib/types/FnCompareTwo.d.ts +1 -0
  129. package/lib/types/FnCompareTwo.js +3 -0
  130. package/lib/types/FnToMemoize.d.ts +1 -0
  131. package/lib/types/FnToMemoize.js +3 -0
  132. package/{src/types/ILinkedList.ts → lib/types/IArrayFacade.d.ts} +4 -6
  133. package/lib/types/IArrayFacade.js +3 -0
  134. package/{src/types/IBiDirectIterable.ts → lib/types/IBiDirectIterable.d.ts} +5 -6
  135. package/lib/types/IBiDirectIterable.js +3 -0
  136. package/lib/types/IBiDirectIterator.d.ts +11 -0
  137. package/lib/types/IBiDirectIterator.js +3 -0
  138. package/lib/types/IBinaryTree.d.ts +12 -0
  139. package/lib/types/IBinaryTree.js +3 -0
  140. package/lib/types/IConvertableToArray.d.ts +4 -0
  141. package/lib/types/IConvertableToArray.js +3 -0
  142. package/lib/types/IGraph.d.ts +14 -0
  143. package/lib/types/IGraph.js +3 -0
  144. package/{src/types/IGraphIterationStrategy.ts → lib/types/IGraphIterationStrategy.d.ts} +5 -6
  145. package/lib/types/IGraphIterationStrategy.js +3 -0
  146. package/lib/types/IGraphIterator.d.ts +11 -0
  147. package/lib/types/IGraphIterator.js +3 -0
  148. package/{src/types/IIterable.ts → lib/types/IIterable.d.ts} +4 -5
  149. package/lib/types/IIterable.js +3 -0
  150. package/lib/types/IIterator.d.ts +14 -0
  151. package/lib/types/IIterator.js +3 -0
  152. package/lib/types/IKeyValueStorage.d.ts +8 -0
  153. package/lib/types/IKeyValueStorage.js +3 -0
  154. package/lib/types/ILinearStorage.d.ts +11 -0
  155. package/lib/types/ILinearStorage.js +3 -0
  156. package/{src/types/ILinearStorageRA.ts → lib/types/ILinearStorageRA.d.ts} +13 -14
  157. package/lib/types/ILinearStorageRA.js +3 -0
  158. package/{src/types/IArrayFacade.ts → lib/types/ILinkedList.d.ts} +4 -6
  159. package/lib/types/ILinkedList.js +3 -0
  160. package/lib/utils.d.ts +29 -0
  161. package/lib/utils.js +95 -0
  162. package/package.json +9 -3
  163. package/.idea/algorythmes.iml +0 -15
  164. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  165. package/.idea/deployment.xml +0 -14
  166. package/.idea/inspectionProfiles/Project_Default.xml +0 -7
  167. package/.idea/jsLinters/eslint.xml +0 -6
  168. package/.idea/misc.xml +0 -6
  169. package/.idea/modules.xml +0 -8
  170. package/.idea/vcs.xml +0 -6
  171. package/lib/algotirhms.ts +0 -35
  172. package/lib/constants.ts +0 -3
  173. package/lib/data-structures.ts +0 -23
  174. package/lib/helpers.ts +0 -13
  175. package/lib/sorts.ts +0 -7
  176. package/lib/types.ts +0 -53
  177. package/lib/utils.ts +0 -21
  178. package/src/algorithms/binary-search.ts +0 -28
  179. package/src/algorithms/factorial.ts +0 -18
  180. package/src/algorithms/fibonacci.ts +0 -18
  181. package/src/algorithms/memoize.ts +0 -21
  182. package/src/algorithms/sorts/bubble-sort.ts +0 -21
  183. package/src/algorithms/sorts/insertion-sort.ts +0 -25
  184. package/src/algorithms/sorts/merge-sort.ts +0 -74
  185. package/src/algorithms/sorts/quick-sort.ts +0 -54
  186. package/src/algorithms/sorts/select-sort.ts +0 -19
  187. package/src/algorithms/transpose-matrix.ts +0 -19
  188. package/src/constants.ts +0 -2
  189. package/src/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryNode.ts +0 -45
  190. package/src/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.ts +0 -80
  191. package/src/data-structures/BinaryTree/BinarySearchTree/BinarySearchNode.ts +0 -38
  192. package/src/data-structures/BinaryTree/BinarySearchTree/BinarySearchTree.ts +0 -286
  193. package/src/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchNode.ts +0 -48
  194. package/src/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchTree.ts +0 -228
  195. package/src/data-structures/Graph/AbstractGraph.ts +0 -189
  196. package/src/data-structures/Graph/DirectedGraph.ts +0 -84
  197. package/src/data-structures/Graph/GraphEdge.ts +0 -33
  198. package/src/data-structures/Graph/UndirectedGraph.ts +0 -108
  199. package/src/data-structures/Graph/demo/generateRandomGraph.ts +0 -93
  200. package/src/data-structures/Graph/iterator/AbstractGraphIterator.ts +0 -99
  201. package/src/data-structures/Graph/iterator/GraphIteratorBFS.ts +0 -60
  202. package/src/data-structures/Graph/iterator/GraphIteratorDFS.ts +0 -60
  203. package/src/data-structures/Graph/iterator/GraphIteratorDijkstra.ts +0 -94
  204. package/src/data-structures/Graph/presenter/presenterAdjacencyLists.ts +0 -29
  205. package/src/data-structures/Graph/searching/hasPath.ts +0 -38
  206. package/src/data-structures/Graph/searching/shortestPath.ts +0 -38
  207. package/src/data-structures/Graph/strategy/BFSIterationStrategy.ts +0 -11
  208. package/src/data-structures/Graph/strategy/DFSIterationStrategy.ts +0 -11
  209. package/src/data-structures/Graph/strategy/DijkstraIterationStrategy.ts +0 -11
  210. package/src/data-structures/Graph/transposing/transposeDirectedGraph.ts +0 -19
  211. package/src/data-structures/HashTable/HashTable.ts +0 -202
  212. package/src/data-structures/HashTable/HashTableNode.ts +0 -31
  213. package/src/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedList.ts +0 -310
  214. package/src/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedNode.ts +0 -33
  215. package/src/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedList.ts +0 -156
  216. package/src/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedNode.ts +0 -47
  217. package/src/data-structures/LinkedList/SingleLinkedList/SingleLinkedList.ts +0 -147
  218. package/src/data-structures/LoopedArray/LoopedArray.ts +0 -182
  219. package/src/data-structures/Queue/Queue.ts +0 -92
  220. package/src/data-structures/Stack/Stack.ts +0 -92
  221. package/src/demo/demo.bst.ts +0 -67
  222. package/src/demo/demo.graph.ts +0 -246
  223. package/src/demo/demo.hashtable.ts +0 -28
  224. package/src/demo/demo.linked-list.ts +0 -78
  225. package/src/demo/demo.looped-array.ts +0 -104
  226. package/src/demo/demo.queue.ts +0 -40
  227. package/src/demo/demo.stack.ts +0 -40
  228. package/src/demo/performance/bst-compare.ts +0 -35
  229. package/src/demo/performance/ds-compare.ts +0 -58
  230. package/src/demo/performance/hash-table.compare.ts +0 -40
  231. package/src/demo/performance/sort-compare.ts +0 -60
  232. package/src/helpers/createBinaryTree.ts +0 -24
  233. package/src/helpers/createGraph.ts +0 -24
  234. package/src/helpers/createGraphFromMatrix.ts +0 -47
  235. package/src/helpers/createLinkedList.ts +0 -24
  236. package/src/index.ts +0 -44
  237. package/src/types/ArrayMatrix.ts +0 -1
  238. package/src/types/EnumBinarySearchTreeType.ts +0 -4
  239. package/src/types/EnumGraphTraversalType.ts +0 -5
  240. package/src/types/EnumGraphType.ts +0 -4
  241. package/src/types/EnumLinkedListType.ts +0 -4
  242. package/src/types/EnumRandomGenerationFormat.ts +0 -4
  243. package/src/types/EnumSortType.ts +0 -7
  244. package/src/types/EnumTreeTraversalType.ts +0 -5
  245. package/src/types/FnCompareTwo.ts +0 -1
  246. package/src/types/FnSort.ts +0 -1
  247. package/src/types/FnToMemoize.ts +0 -1
  248. package/src/types/IBiDirectIterator.ts +0 -12
  249. package/src/types/IBinaryTree.ts +0 -13
  250. package/src/types/IConvertableToArray.ts +0 -4
  251. package/src/types/IGraph.ts +0 -16
  252. package/src/types/IGraphCreator.ts +0 -5
  253. package/src/types/IGraphIterator.ts +0 -13
  254. package/src/types/IIterator.ts +0 -14
  255. package/src/types/IKeyValueStorage.ts +0 -8
  256. package/src/types/ILinearStorage.ts +0 -11
  257. package/src/utils.ts +0 -65
@@ -1,15 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="WEB_MODULE" version="4">
3
- <component name="NewModuleRootManager">
4
- <content url="file://$MODULE_DIR$">
5
- <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
6
- <excludeFolder url="file://$MODULE_DIR$/.tmp" />
7
- <excludeFolder url="file://$MODULE_DIR$/temp" />
8
- <excludeFolder url="file://$MODULE_DIR$/tmp" />
9
- <excludeFolder url="file://$MODULE_DIR$/build/coverage" />
10
- <excludeFolder url="file://$MODULE_DIR$/coverage" />
11
- </content>
12
- <orderEntry type="inheritedJdk" />
13
- <orderEntry type="sourceFolder" forTests="false" />
14
- </component>
15
- </module>
@@ -1,5 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <state>
3
- <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
4
- </state>
5
- </component>
@@ -1,14 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="PublishConfigData">
4
- <serverData>
5
- <paths name="raikuhost">
6
- <serverdata>
7
- <mappings>
8
- <mapping local="$PROJECT_DIR$" web="/" />
9
- </mappings>
10
- </serverdata>
11
- </paths>
12
- </serverData>
13
- </component>
14
- </project>
@@ -1,7 +0,0 @@
1
- <component name="InspectionProjectProfileManager">
2
- <profile version="1.0">
3
- <option name="myName" value="Project Default" />
4
- <inspection_tool class="DuplicatedCode" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
5
- <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
6
- </profile>
7
- </component>
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="EslintConfiguration">
4
- <option name="fix-on-save" value="true" />
5
- </component>
6
- </project>
package/.idea/misc.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="JavaScriptSettings">
4
- <option name="languageLevel" value="ES6" />
5
- </component>
6
- </project>
package/.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/algorythmes.iml" filepath="$PROJECT_DIR$/.idea/algorythmes.iml" />
6
- </modules>
7
- </component>
8
- </project>
package/.idea/vcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
- </component>
6
- </project>
package/lib/algotirhms.ts DELETED
@@ -1,35 +0,0 @@
1
- import { factorial, memoizedFactorial } from "../src/algorithms/factorial";
2
- import { fibonacci, memoizedFibonacci } from "../src/algorithms/fibonacci";
3
- import { binarySearch } from "../src/algorithms/binary-search";
4
- import { transposeMatrix } from "../src/algorithms/transpose-matrix";
5
- import { transposeDirectedGraph } from "../src/data-structures/Graph/transposing/transposeDirectedGraph";
6
- import BFSIterationStrategy from "../src/data-structures/Graph/strategy/BFSIterationStrategy";
7
- import DFSIterationStrategy from "../src/data-structures/Graph/strategy/DFSIterationStrategy";
8
- import DijkstraIterationStrategy from "../src/data-structures/Graph/strategy/DijkstraIterationStrategy";
9
- import GraphIteratorBFS from "../src/data-structures/Graph/iterator/GraphIteratorBFS";
10
- import GraphIteratorDFS from "../src/data-structures/Graph/iterator/GraphIteratorDFS";
11
- import GraphIteratorDijkstra from "../src/data-structures/Graph/iterator/GraphIteratorDijkstra";
12
- import { hasPath } from "../src/data-structures/Graph/searching/hasPath";
13
- import { shortestPath } from "../src/data-structures/Graph/searching/shortestPath";
14
- import { presenterAdjacencyMatrix } from "../src/data-structures/Graph/presenter/presenterAdjacencyMatrix";
15
- import { presenterAdjacencyLists } from "../src/data-structures/Graph/presenter/presenterAdjacencyLists";
16
-
17
- export {
18
- binarySearch,
19
- factorial,
20
- memoizedFactorial,
21
- memoizedFibonacci,
22
- fibonacci,
23
- transposeMatrix,
24
- GraphIteratorDFS,
25
- presenterAdjacencyLists,
26
- presenterAdjacencyMatrix,
27
- hasPath,
28
- shortestPath,
29
- DijkstraIterationStrategy,
30
- DFSIterationStrategy,
31
- BFSIterationStrategy,
32
- GraphIteratorBFS,
33
- GraphIteratorDijkstra,
34
- transposeDirectedGraph,
35
- };
package/lib/constants.ts DELETED
@@ -1,3 +0,0 @@
1
- import { EDGE_EXISTS_STATE, EDGE_NOT_EXISTS_STATE } from "../src/constants";
2
-
3
- export { EDGE_NOT_EXISTS_STATE, EDGE_EXISTS_STATE };
@@ -1,23 +0,0 @@
1
- import Queue from "../src/data-structures/Queue/Queue";
2
- import Stack from "../src/data-structures/Stack/Stack";
3
- import UndirectedGraph from "../src/data-structures/Graph/UndirectedGraph";
4
- import DirectedGraph from "../src/data-structures/Graph/DirectedGraph";
5
- import BinarySearchTree from "../src/data-structures/BinaryTree/BinarySearchTree/BinarySearchTree";
6
- import RandBinarySearchTree from "../src/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchTree";
7
- import DoubleLinkedList from "../src/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedList";
8
- import SingleLinkedList from "../src/data-structures/LinkedList/SingleLinkedList/SingleLinkedList";
9
- import LoopedArray from "../src/data-structures/LoopedArray/LoopedArray";
10
- import HashTable from "../src/data-structures/HashTable/HashTable";
11
-
12
- export {
13
- Stack,
14
- Queue,
15
- SingleLinkedList,
16
- DoubleLinkedList,
17
- RandBinarySearchTree,
18
- BinarySearchTree,
19
- DirectedGraph,
20
- UndirectedGraph,
21
- LoopedArray,
22
- HashTable,
23
- };
package/lib/helpers.ts DELETED
@@ -1,13 +0,0 @@
1
- import { generateRandomGraph } from "../src/data-structures/Graph/demo/generateRandomGraph";
2
- import { createLinkedList } from "../src/helpers/createLinkedList";
3
- import { createBinaryTree } from "../src/helpers/createBinaryTree";
4
- import { createGraph } from "../src/helpers/createGraph";
5
- import { createGraphFromMatrix } from "../src/helpers/createGraphFromMatrix";
6
-
7
- export {
8
- createGraph,
9
- createGraphFromMatrix,
10
- createBinaryTree,
11
- createLinkedList,
12
- generateRandomGraph,
13
- };
package/lib/sorts.ts DELETED
@@ -1,7 +0,0 @@
1
- import { bubbleSort } from "../src/algorithms/sorts/bubble-sort";
2
- import { selectSort } from "../src/algorithms/sorts/select-sort";
3
- import { mergeSort } from "../src/algorithms/sorts/merge-sort";
4
- import { insertionSort } from "../src/algorithms/sorts/insertion-sort";
5
- import { quickSort } from "../src/algorithms/sorts/quick-sort";
6
-
7
- export { bubbleSort, insertionSort, mergeSort, selectSort, quickSort };
package/lib/types.ts DELETED
@@ -1,53 +0,0 @@
1
- import { ArrayMatrix } from "../src/types/ArrayMatrix";
2
- import { EnumTreeTraversalType } from "../src/types/EnumTreeTraversalType";
3
- import { EnumBinarySearchTreeType } from "../src/types/EnumBinarySearchTreeType";
4
- import { EnumGraphTraversalType } from "../src/types/EnumGraphTraversalType";
5
- import { EnumGraphType } from "../src/types/EnumGraphType";
6
- import { EnumLinkedListType } from "../src/types/EnumLinkedListType";
7
- import { EnumRandomGenerationFormat } from "../src/types/EnumRandomGenerationFormat";
8
- import { EnumSortType } from "../src/types/EnumSortType";
9
- import { FnSort } from "../src/types/FnSort";
10
- import { FnCompareTwo } from "../src/types/FnCompareTwo";
11
- import { FnToMemoize } from "../src/types/FnToMemoize";
12
- import IArrayFacade from "../src/types/IArrayFacade";
13
- import IBiDirectIterator from "../src/types/IBiDirectIterator";
14
- import IBiDirectIterable from "../src/types/IBiDirectIterable";
15
- import IIterable from "../src/types/IIterable";
16
- import IIterator from "../src/types/IIterator";
17
- import IBinaryTree from "../src/types/IBinaryTree";
18
- import IConvertableToArray from "../src/types/IConvertableToArray";
19
- import IGraph from "../src/types/IGraph";
20
- import IGraphCreator from "../src/types/IGraphCreator";
21
- import IGraphIterationStrategy from "../src/types/IGraphIterationStrategy";
22
- import IGraphIterator from "../src/types/IGraphIterator";
23
- import ILinearStorage from "../src/types/ILinearStorage";
24
- import ILinearStorageRA from "../src/types/ILinearStorageRA";
25
- import ILinkedList from "../src/types/ILinkedList";
26
-
27
- export {
28
- IGraph,
29
- IGraphIterator,
30
- IGraphIterationStrategy,
31
- IIterator,
32
- IIterable,
33
- IGraphCreator,
34
- IBiDirectIterable,
35
- IBiDirectIterator,
36
- EnumGraphType,
37
- EnumSortType,
38
- FnSort,
39
- EnumGraphTraversalType,
40
- EnumTreeTraversalType,
41
- EnumBinarySearchTreeType,
42
- IBinaryTree,
43
- EnumLinkedListType,
44
- ILinkedList,
45
- ILinearStorage,
46
- ILinearStorageRA,
47
- IArrayFacade,
48
- IConvertableToArray,
49
- ArrayMatrix,
50
- FnCompareTwo,
51
- EnumRandomGenerationFormat,
52
- FnToMemoize,
53
- };
package/lib/utils.ts DELETED
@@ -1,21 +0,0 @@
1
- import { memoize } from "../src/algorithms/memoize";
2
- import {
3
- getMinIndex,
4
- getMinIndexFromIndex,
5
- perf,
6
- randomizeNumberInRange,
7
- roundNumber,
8
- swapArrayItems,
9
- perfAsync,
10
- } from "../src/utils";
11
-
12
- export {
13
- perf,
14
- getMinIndex,
15
- getMinIndexFromIndex,
16
- memoize,
17
- perfAsync,
18
- roundNumber,
19
- randomizeNumberInRange,
20
- swapArrayItems,
21
- };
@@ -1,28 +0,0 @@
1
- /**
2
- * Find element's index in sorted array
3
- * Time complexity: O(log(n))
4
- */
5
- export const binarySearch = (
6
- elements: Array<number>,
7
- searchElement: number
8
- ): number | null => {
9
- const length: number = elements.length;
10
-
11
- let leftIndex = 0;
12
- let rightIndex: number = length - 1;
13
-
14
- while (leftIndex <= rightIndex) {
15
- const midIndex: number = Math.ceil((leftIndex + rightIndex) / 2);
16
- const midEl: number = elements[midIndex];
17
-
18
- if (searchElement == midEl) {
19
- return midIndex;
20
- } else if (midEl > searchElement) {
21
- rightIndex = midIndex - 1;
22
- } else if (midEl < searchElement) {
23
- leftIndex = midIndex + 1;
24
- }
25
- }
26
-
27
- return null;
28
- };
@@ -1,18 +0,0 @@
1
- import { memoize } from "./memoize";
2
- import { FnToMemoize } from "../types/FnToMemoize";
3
-
4
- /**
5
- * Time complexity: O(n!)
6
- */
7
- export const factorial = (x: number): number => {
8
- return x > 1 ? x * factorial(x - 1) : x;
9
- };
10
-
11
- /**
12
- * Time complexity: O(n) - due to caching
13
- */
14
- export const memoizedFactorial: FnToMemoize<number, number> = memoize(
15
- (n: number) => {
16
- return n > 1 ? n * memoizedFactorial(n - 1) : n;
17
- }
18
- );
@@ -1,18 +0,0 @@
1
- import { FnToMemoize } from "../types/FnToMemoize";
2
- import { memoize } from "./memoize";
3
-
4
- /**
5
- * Time complexity: O(n!)
6
- */
7
- export const fibonacci = (n: number): number => {
8
- return n > 1 ? fibonacci(n - 1) + fibonacci(n - 2) : n;
9
- };
10
-
11
- /**
12
- * Time complexity: O(n) - due to caching
13
- */
14
- export const memoizedFibonacci: FnToMemoize<number, number> = memoize(
15
- (n: number) => {
16
- return n > 1 ? memoizedFibonacci(n - 1) + memoizedFibonacci(n - 2) : n;
17
- }
18
- );
@@ -1,21 +0,0 @@
1
- import { FnToMemoize } from "../types/FnToMemoize";
2
-
3
- /**
4
- * Wrapper function that storing the results of calls and returning the cached result when the same inputs occur again
5
- */
6
- export const memoize = <Key, Value>(
7
- fn: FnToMemoize<Key, Value>
8
- ): FnToMemoize<Key, Value> => {
9
- const cache = new Map<string, Value>();
10
-
11
- return (...args: Array<Key>): Value => {
12
- const jsonArgs = JSON.stringify(args);
13
-
14
- if (!cache.has(jsonArgs)) {
15
- const result = fn(...args);
16
- cache.set(jsonArgs, result);
17
- }
18
-
19
- return <Value>cache.get(jsonArgs);
20
- };
21
- };
@@ -1,21 +0,0 @@
1
- import { swapArrayItems } from "../../utils";
2
-
3
- /**
4
- * Bubble sorting algorithm
5
- *
6
- * @description
7
- * Time complexity: Best O(n); Avg O(n \^ 2); Worst O(n \^ 2)
8
- * @description
9
- * Memory complexity: Worst case: O(1)
10
- */
11
- export const bubbleSort = (arr: Array<number>): Array<number> => {
12
- for (let i = 0; i < arr.length - 1; i++) {
13
- for (let j = 0; j < arr.length - 1; j++) {
14
- if (arr[j] > arr[j + 1]) {
15
- swapArrayItems(arr, j, j + 1);
16
- }
17
- }
18
- }
19
-
20
- return arr;
21
- };
@@ -1,25 +0,0 @@
1
- import { swapArrayItems } from "../../utils";
2
-
3
- /**
4
- * Insertion sorting algorithm
5
- *
6
- * @description
7
- * Time complexity: Best O(n); Avg O(n \^ 2); Worst O(n \^ 2);
8
- * @description
9
- * Memory complexity: Worst case: O(1)
10
- */
11
- export const insertionSort = (arr: Array<number>): Array<number> => {
12
- for (let i = 1; i < arr.length; i++) {
13
- const current = arr[i];
14
- let j = i - 1;
15
-
16
- while (j >= 0 && arr[j] > current) {
17
- swapArrayItems(arr, j + 1, j);
18
- j--;
19
- }
20
-
21
- arr[j + 1] = current;
22
- }
23
-
24
- return arr;
25
- };
@@ -1,74 +0,0 @@
1
- /**
2
- * Merge two sorted arrays into one array
3
- */
4
- const merge = (
5
- arr: Array<number>,
6
- leftIndex: number,
7
- midIndex: number,
8
- rightIndex: number
9
- ) => {
10
- const container = arr.slice(leftIndex, rightIndex + 1);
11
-
12
- let resultArrIndex = leftIndex;
13
- let leftHalfIndex = leftIndex;
14
- let rightHalfIndex = midIndex + 1;
15
-
16
- /** While both halves of array are not ended */
17
- while (leftHalfIndex <= midIndex && rightHalfIndex <= rightIndex) {
18
- const leftHalfElement = container[leftHalfIndex - leftIndex];
19
- const rightHalfElement = container[rightHalfIndex - leftIndex];
20
-
21
- if (leftHalfElement < rightHalfElement) {
22
- arr[resultArrIndex] = leftHalfElement;
23
- leftHalfIndex++;
24
- } else {
25
- arr[resultArrIndex] = rightHalfElement;
26
- rightHalfIndex++;
27
- }
28
- resultArrIndex++;
29
- }
30
-
31
- /** If one of halves is ended, the remaining one will just be pushed to result */
32
- while (leftHalfIndex <= midIndex) {
33
- arr[resultArrIndex] = container[leftHalfIndex - leftIndex];
34
- resultArrIndex++;
35
- leftHalfIndex++;
36
- }
37
- while (rightHalfIndex <= rightIndex) {
38
- arr[resultArrIndex] = container[rightHalfIndex - leftIndex];
39
- resultArrIndex++;
40
- rightHalfIndex++;
41
- }
42
- };
43
-
44
- /**
45
- * Divide array into 2 halves and merge them
46
- */
47
- const sortRange = (
48
- arr: Array<number>,
49
- leftIndex: number,
50
- rightIndex: number
51
- ) => {
52
- if (rightIndex > leftIndex) {
53
- const midIndex = Math.floor(leftIndex + (rightIndex - leftIndex) / 2);
54
-
55
- sortRange(arr, leftIndex, midIndex);
56
- sortRange(arr, midIndex + 1, rightIndex);
57
-
58
- merge(arr, leftIndex, midIndex, rightIndex);
59
- }
60
- };
61
-
62
- /**
63
- * Merge sorting algorithm
64
- *
65
- * @description
66
- * Time complexity: Best O(n * log(n)); Avg O(n * log(n)); Worst O(n * log(n))
67
- * @description
68
- * Memory complexity: Worst case: O(n)
69
- */
70
- export const mergeSort = (arr: Array<number>): Array<number> => {
71
- sortRange(arr, 0, arr.length - 1);
72
-
73
- return arr;
74
- };
@@ -1,54 +0,0 @@
1
- import { swapArrayItems } from "../../utils";
2
-
3
- /**
4
- * Quick sort algorithm
5
- *
6
- * @description
7
- * Time complexity: Best O(n * log(n)); Avg O(n * log(n)); Worst O(n ^2)
8
- * @description
9
- * Memory complexity: Worst case: O(1)
10
- */
11
- export const quickSort = (arr: Array<number>): Array<number> => {
12
- const partition = (
13
- arr: Array<number>,
14
- leftIndex: number,
15
- rightIndex: number
16
- ): number => {
17
- const pivot = arr[leftIndex];
18
-
19
- let leftWall = leftIndex;
20
- let rightWall = rightIndex;
21
-
22
- while (leftWall <= rightWall) {
23
- while (arr[rightWall] > pivot) {
24
- rightWall--;
25
- }
26
- while (arr[leftWall] < pivot) {
27
- leftWall++;
28
- }
29
- if (leftWall <= rightWall) {
30
- swapArrayItems(arr, leftWall, rightWall);
31
- rightWall--;
32
- leftWall++;
33
- }
34
- }
35
-
36
- return leftWall;
37
- };
38
-
39
- const sort = (
40
- arr: Array<number>,
41
- leftIndex = 0,
42
- rightIndex: number = arr.length - 1
43
- ): Array<number> => {
44
- if (leftIndex < rightIndex) {
45
- const pivot = partition(arr, leftIndex, rightIndex);
46
-
47
- sort(arr, leftIndex, pivot - 1);
48
- sort(arr, pivot, rightIndex);
49
- }
50
- return arr;
51
- };
52
-
53
- return sort(arr);
54
- };
@@ -1,19 +0,0 @@
1
- import { swapArrayItems, getMinIndexFromIndex } from "../../utils";
2
-
3
- /**
4
- * Selection sorting algorithm
5
- *
6
- * @description
7
- * Time complexity: Best O(n \^ 2); Avg O(n \^ 2); Worst O(n \^ 2)
8
- * @description
9
- * Memory complexity: Worst case: O(1)
10
- */
11
- export const selectSort = (arr: Array<number>): Array<number> => {
12
- for (let index = 0; index < arr.length; index++) {
13
- const minIndex: number = getMinIndexFromIndex(arr, index);
14
-
15
- swapArrayItems<number>(arr, minIndex, index);
16
- }
17
-
18
- return arr;
19
- };
@@ -1,19 +0,0 @@
1
- import { ArrayMatrix } from "../types/ArrayMatrix";
2
-
3
- /**
4
- * Will flips a matrix over its diagonal
5
- */
6
- export const transposeMatrix = (matrix: ArrayMatrix): ArrayMatrix => {
7
- /** Validation */
8
- matrix.forEach((subArray) => {
9
- const checkIsSameLength = subArray.length === matrix.length;
10
- if (!checkIsSameLength) {
11
- throw new Error("Given array is not a matrix");
12
- }
13
- });
14
-
15
- return matrix.reduce((acc, current, currentIndex) => {
16
- acc[currentIndex] = matrix.map((rowArr) => rowArr[currentIndex]);
17
- return acc;
18
- }, new Array(matrix.length));
19
- };
package/src/constants.ts DELETED
@@ -1,2 +0,0 @@
1
- export const EDGE_EXISTS_STATE = 1;
2
- export const EDGE_NOT_EXISTS_STATE = 0;
@@ -1,45 +0,0 @@
1
- export default abstract class AbstractBinaryNode<T> {
2
- protected _data: T;
3
- protected _left: AbstractBinaryNode<T> | null;
4
- protected _right: AbstractBinaryNode<T> | null;
5
- protected _parent: AbstractBinaryNode<T> | null;
6
-
7
- protected constructor(initialData: T) {
8
- this._data = initialData;
9
- this._left = null;
10
- this._right = null;
11
- this._parent = null;
12
- }
13
-
14
- public get data(): T {
15
- return this._data;
16
- }
17
-
18
- public set data(value: T) {
19
- this._data = value;
20
- }
21
-
22
- public get left(): AbstractBinaryNode<T> | null {
23
- return this._left;
24
- }
25
-
26
- public set left(value: AbstractBinaryNode<T> | null) {
27
- this._left = value;
28
- }
29
-
30
- public get right(): AbstractBinaryNode<T> | null {
31
- return this._right;
32
- }
33
-
34
- public set right(value: AbstractBinaryNode<T> | null) {
35
- this._right = value;
36
- }
37
-
38
- public get parent(): AbstractBinaryNode<T> | null {
39
- return this._parent;
40
- }
41
-
42
- public set parent(value: AbstractBinaryNode<T> | null) {
43
- this._parent = value;
44
- }
45
- }