data-structure-typed 1.37.3 → 1.37.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 (346) hide show
  1. package/dist/data-structures/binary-tree/avl-tree.d.ts +42 -34
  2. package/dist/data-structures/binary-tree/avl-tree.js +42 -34
  3. package/dist/data-structures/binary-tree/avl-tree.js.map +1 -1
  4. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +141 -43
  5. package/dist/data-structures/binary-tree/binary-indexed-tree.js +230 -42
  6. package/dist/data-structures/binary-tree/binary-indexed-tree.js.map +1 -1
  7. package/dist/data-structures/binary-tree/binary-tree.d.ts +265 -168
  8. package/dist/data-structures/binary-tree/binary-tree.js +257 -170
  9. package/dist/data-structures/binary-tree/binary-tree.js.map +1 -1
  10. package/dist/data-structures/binary-tree/bst.d.ts +104 -59
  11. package/dist/data-structures/binary-tree/bst.js +105 -60
  12. package/dist/data-structures/binary-tree/bst.js.map +1 -1
  13. package/dist/data-structures/binary-tree/tree-multiset.d.ts +47 -39
  14. package/dist/data-structures/binary-tree/tree-multiset.js +47 -39
  15. package/dist/data-structures/binary-tree/tree-multiset.js.map +1 -1
  16. package/{lib/types/data-structures → dist/types/data-structures/binary-tree}/avl-tree.d.ts +1 -1
  17. package/dist/types/data-structures/binary-tree/avl-tree.js.map +1 -0
  18. package/dist/types/data-structures/binary-tree/binary-indexed-tree.js +3 -0
  19. package/dist/types/data-structures/binary-tree/binary-indexed-tree.js.map +1 -0
  20. package/dist/types/data-structures/{binary-tree.d.ts → binary-tree/binary-tree.d.ts} +1 -5
  21. package/dist/types/data-structures/binary-tree/binary-tree.js.map +1 -0
  22. package/dist/types/data-structures/{bst.d.ts → binary-tree/bst.d.ts} +1 -1
  23. package/dist/types/data-structures/binary-tree/bst.js.map +1 -0
  24. package/dist/types/data-structures/binary-tree/index.d.ts +6 -0
  25. package/dist/types/data-structures/binary-tree/index.js +23 -0
  26. package/dist/types/data-structures/binary-tree/index.js.map +1 -0
  27. package/dist/types/data-structures/{rb-tree.d.ts → binary-tree/rb-tree.d.ts} +1 -1
  28. package/dist/types/data-structures/binary-tree/rb-tree.js.map +1 -0
  29. package/dist/types/data-structures/binary-tree/segment-tree.js.map +1 -0
  30. package/dist/types/data-structures/{tree-multiset.d.ts → binary-tree/tree-multiset.d.ts} +1 -1
  31. package/dist/types/data-structures/binary-tree/tree-multiset.js.map +1 -0
  32. package/dist/types/data-structures/graph/abstract-graph.js.map +1 -0
  33. package/dist/types/data-structures/graph/directed-graph.js.map +1 -0
  34. package/dist/types/data-structures/graph/index.d.ts +3 -0
  35. package/dist/types/data-structures/graph/index.js +20 -0
  36. package/dist/types/data-structures/graph/index.js.map +1 -0
  37. package/dist/types/data-structures/graph/map-graph.js.map +1 -0
  38. package/dist/types/data-structures/graph/undirected-graph.js +3 -0
  39. package/dist/types/data-structures/graph/undirected-graph.js.map +1 -0
  40. package/dist/types/data-structures/hash/coordinate-map.js +3 -0
  41. package/dist/types/data-structures/hash/coordinate-map.js.map +1 -0
  42. package/dist/types/data-structures/hash/coordinate-set.js +3 -0
  43. package/dist/types/data-structures/hash/coordinate-set.js.map +1 -0
  44. package/dist/types/data-structures/hash/hash-map.js +3 -0
  45. package/dist/types/data-structures/hash/hash-map.js.map +1 -0
  46. package/dist/types/data-structures/hash/hash-table.js +3 -0
  47. package/dist/types/data-structures/hash/hash-table.js.map +1 -0
  48. package/dist/types/data-structures/hash/index.js +3 -0
  49. package/dist/types/data-structures/hash/index.js.map +1 -0
  50. package/dist/types/data-structures/hash/tree-map.js +3 -0
  51. package/dist/types/data-structures/hash/tree-map.js.map +1 -0
  52. package/dist/types/data-structures/hash/tree-set.js +3 -0
  53. package/dist/types/data-structures/hash/tree-set.js.map +1 -0
  54. package/dist/types/data-structures/heap/heap.js.map +1 -0
  55. package/dist/types/data-structures/heap/index.d.ts +1 -0
  56. package/dist/types/data-structures/heap/index.js +18 -0
  57. package/dist/types/data-structures/heap/index.js.map +1 -0
  58. package/dist/types/data-structures/heap/max-heap.js +3 -0
  59. package/dist/types/data-structures/heap/max-heap.js.map +1 -0
  60. package/dist/types/data-structures/heap/min-heap.js +3 -0
  61. package/dist/types/data-structures/heap/min-heap.js.map +1 -0
  62. package/dist/types/data-structures/index.d.ts +8 -13
  63. package/dist/types/data-structures/index.js +8 -11
  64. package/dist/types/data-structures/index.js.map +1 -1
  65. package/dist/types/data-structures/linked-list/doubly-linked-list.js.map +1 -0
  66. package/dist/types/data-structures/linked-list/index.d.ts +2 -0
  67. package/dist/types/data-structures/linked-list/index.js +19 -0
  68. package/dist/types/data-structures/linked-list/index.js.map +1 -0
  69. package/dist/types/data-structures/linked-list/singly-linked-list.js.map +1 -0
  70. package/dist/types/data-structures/linked-list/skip-linked-list.js +3 -0
  71. package/dist/types/data-structures/linked-list/skip-linked-list.js.map +1 -0
  72. package/dist/types/data-structures/matrix/index.d.ts +1 -0
  73. package/dist/types/data-structures/matrix/index.js +18 -0
  74. package/dist/types/data-structures/matrix/index.js.map +1 -0
  75. package/dist/types/data-structures/matrix/matrix.js +3 -0
  76. package/dist/types/data-structures/matrix/matrix.js.map +1 -0
  77. package/dist/types/data-structures/matrix/matrix2d.js +3 -0
  78. package/dist/types/data-structures/matrix/matrix2d.js.map +1 -0
  79. package/dist/types/data-structures/matrix/navigator.js.map +1 -0
  80. package/dist/types/data-structures/matrix/vector2d.js +3 -0
  81. package/dist/types/data-structures/matrix/vector2d.js.map +1 -0
  82. package/dist/types/data-structures/priority-queue/index.d.ts +3 -0
  83. package/dist/types/data-structures/priority-queue/index.js +20 -0
  84. package/dist/types/data-structures/priority-queue/index.js.map +1 -0
  85. package/dist/types/data-structures/priority-queue/max-priority-queue.js +3 -0
  86. package/dist/types/data-structures/priority-queue/max-priority-queue.js.map +1 -0
  87. package/dist/types/data-structures/priority-queue/min-priority-queue.js +3 -0
  88. package/dist/types/data-structures/priority-queue/min-priority-queue.js.map +1 -0
  89. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
  90. package/dist/types/data-structures/priority-queue/priority-queue.js +3 -0
  91. package/dist/types/data-structures/priority-queue/priority-queue.js.map +1 -0
  92. package/dist/types/data-structures/queue/deque.d.ts +1 -0
  93. package/dist/types/data-structures/queue/deque.js +3 -0
  94. package/dist/types/data-structures/queue/deque.js.map +1 -0
  95. package/dist/types/data-structures/queue/index.d.ts +2 -0
  96. package/dist/types/data-structures/queue/index.js +19 -0
  97. package/dist/types/data-structures/queue/index.js.map +1 -0
  98. package/dist/types/data-structures/queue/queue.d.ts +1 -0
  99. package/dist/types/data-structures/queue/queue.js +3 -0
  100. package/dist/types/data-structures/queue/queue.js.map +1 -0
  101. package/dist/types/data-structures/stack/index.d.ts +1 -0
  102. package/dist/types/data-structures/stack/index.js +18 -0
  103. package/dist/types/data-structures/stack/index.js.map +1 -0
  104. package/dist/types/data-structures/stack/stack.d.ts +1 -0
  105. package/dist/types/data-structures/stack/stack.js +3 -0
  106. package/dist/types/data-structures/stack/stack.js.map +1 -0
  107. package/dist/types/data-structures/tree/index.d.ts +1 -0
  108. package/dist/types/data-structures/tree/index.js +18 -0
  109. package/dist/types/data-structures/tree/index.js.map +1 -0
  110. package/dist/types/data-structures/tree/tree.d.ts +1 -0
  111. package/dist/types/data-structures/{hash.js → tree/tree.js} +1 -1
  112. package/dist/types/data-structures/tree/tree.js.map +1 -0
  113. package/dist/types/data-structures/trie/index.d.ts +1 -0
  114. package/dist/types/data-structures/trie/index.js +18 -0
  115. package/dist/types/data-structures/trie/index.js.map +1 -0
  116. package/dist/types/data-structures/trie/trie.d.ts +1 -0
  117. package/dist/types/data-structures/trie/trie.js +3 -0
  118. package/dist/types/data-structures/trie/trie.js.map +1 -0
  119. package/dist/types/helpers.d.ts +2 -0
  120. package/dist/utils/utils.d.ts +1 -0
  121. package/dist/utils/utils.js +8 -1
  122. package/dist/utils/utils.js.map +1 -1
  123. package/lib/data-structures/binary-tree/avl-tree.d.ts +42 -34
  124. package/lib/data-structures/binary-tree/avl-tree.js +42 -34
  125. package/lib/data-structures/binary-tree/binary-indexed-tree.d.ts +141 -43
  126. package/lib/data-structures/binary-tree/binary-indexed-tree.js +230 -42
  127. package/lib/data-structures/binary-tree/binary-tree.d.ts +265 -168
  128. package/lib/data-structures/binary-tree/binary-tree.js +257 -170
  129. package/lib/data-structures/binary-tree/bst.d.ts +104 -59
  130. package/lib/data-structures/binary-tree/bst.js +105 -60
  131. package/lib/data-structures/binary-tree/tree-multiset.d.ts +47 -39
  132. package/lib/data-structures/binary-tree/tree-multiset.js +47 -39
  133. package/{dist/types/data-structures → lib/types/data-structures/binary-tree}/avl-tree.d.ts +1 -1
  134. package/lib/types/data-structures/binary-tree/avl-tree.js +1 -0
  135. package/lib/types/data-structures/binary-tree/binary-indexed-tree.d.ts +1 -0
  136. package/lib/types/data-structures/binary-tree/binary-indexed-tree.js +1 -0
  137. package/lib/types/data-structures/{binary-tree.d.ts → binary-tree/binary-tree.d.ts} +1 -5
  138. package/lib/types/data-structures/{bst.d.ts → binary-tree/bst.d.ts} +1 -1
  139. package/lib/types/data-structures/binary-tree/index.d.ts +6 -0
  140. package/lib/types/data-structures/binary-tree/index.js +6 -0
  141. package/lib/types/data-structures/{rb-tree.d.ts → binary-tree/rb-tree.d.ts} +1 -1
  142. package/lib/types/data-structures/binary-tree/segment-tree.js +1 -0
  143. package/lib/types/data-structures/{tree-multiset.d.ts → binary-tree/tree-multiset.d.ts} +1 -1
  144. package/lib/types/data-structures/binary-tree/tree-multiset.js +1 -0
  145. package/lib/types/data-structures/graph/abstract-graph.js +1 -0
  146. package/lib/types/data-structures/graph/index.d.ts +3 -0
  147. package/lib/types/data-structures/graph/index.js +3 -0
  148. package/lib/types/data-structures/graph/map-graph.js +1 -0
  149. package/lib/types/data-structures/graph/undirected-graph.d.ts +1 -0
  150. package/lib/types/data-structures/graph/undirected-graph.js +1 -0
  151. package/lib/types/data-structures/hash/coordinate-map.d.ts +1 -0
  152. package/lib/types/data-structures/hash/coordinate-map.js +1 -0
  153. package/lib/types/data-structures/hash/coordinate-set.d.ts +1 -0
  154. package/lib/types/data-structures/hash/coordinate-set.js +1 -0
  155. package/lib/types/data-structures/hash/hash-map.d.ts +1 -0
  156. package/lib/types/data-structures/hash/hash-map.js +1 -0
  157. package/lib/types/data-structures/hash/hash-table.d.ts +1 -0
  158. package/lib/types/data-structures/hash/hash-table.js +1 -0
  159. package/lib/types/data-structures/hash/index.js +1 -0
  160. package/lib/types/data-structures/hash/tree-map.d.ts +1 -0
  161. package/lib/types/data-structures/hash/tree-map.js +1 -0
  162. package/lib/types/data-structures/hash/tree-set.d.ts +1 -0
  163. package/lib/types/data-structures/hash/tree-set.js +1 -0
  164. package/lib/types/data-structures/heap/heap.d.ts +1 -0
  165. package/lib/types/data-structures/heap/heap.js +1 -0
  166. package/lib/types/data-structures/heap/index.d.ts +1 -0
  167. package/lib/types/data-structures/heap/index.js +1 -0
  168. package/lib/types/data-structures/heap/max-heap.d.ts +1 -0
  169. package/lib/types/data-structures/heap/max-heap.js +1 -0
  170. package/lib/types/data-structures/heap/min-heap.d.ts +1 -0
  171. package/lib/types/data-structures/heap/min-heap.js +1 -0
  172. package/lib/types/data-structures/index.d.ts +8 -13
  173. package/lib/types/data-structures/index.js +8 -11
  174. package/lib/types/data-structures/linked-list/doubly-linked-list.d.ts +1 -0
  175. package/lib/types/data-structures/linked-list/doubly-linked-list.js +1 -0
  176. package/lib/types/data-structures/linked-list/index.d.ts +2 -0
  177. package/lib/types/data-structures/linked-list/index.js +2 -0
  178. package/lib/types/data-structures/linked-list/singly-linked-list.d.ts +1 -0
  179. package/lib/types/data-structures/linked-list/singly-linked-list.js +1 -0
  180. package/lib/types/data-structures/linked-list/skip-linked-list.d.ts +1 -0
  181. package/lib/types/data-structures/linked-list/skip-linked-list.js +1 -0
  182. package/lib/types/data-structures/matrix/index.d.ts +1 -0
  183. package/lib/types/data-structures/matrix/index.js +1 -0
  184. package/lib/types/data-structures/matrix/matrix.d.ts +1 -0
  185. package/lib/types/data-structures/matrix/matrix.js +1 -0
  186. package/lib/types/data-structures/matrix/matrix2d.d.ts +1 -0
  187. package/lib/types/data-structures/matrix/matrix2d.js +1 -0
  188. package/lib/types/data-structures/matrix/navigator.js +1 -0
  189. package/lib/types/data-structures/matrix/vector2d.d.ts +1 -0
  190. package/lib/types/data-structures/matrix/vector2d.js +1 -0
  191. package/lib/types/data-structures/priority-queue/index.d.ts +3 -0
  192. package/lib/types/data-structures/priority-queue/index.js +3 -0
  193. package/lib/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -0
  194. package/lib/types/data-structures/priority-queue/max-priority-queue.js +1 -0
  195. package/lib/types/data-structures/priority-queue/min-priority-queue.d.ts +1 -0
  196. package/lib/types/data-structures/priority-queue/min-priority-queue.js +1 -0
  197. package/lib/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
  198. package/lib/types/data-structures/priority-queue/priority-queue.js +1 -0
  199. package/lib/types/data-structures/queue/deque.d.ts +1 -0
  200. package/lib/types/data-structures/queue/deque.js +1 -0
  201. package/lib/types/data-structures/queue/index.d.ts +2 -0
  202. package/lib/types/data-structures/queue/index.js +2 -0
  203. package/lib/types/data-structures/queue/queue.d.ts +1 -0
  204. package/lib/types/data-structures/queue/queue.js +1 -0
  205. package/lib/types/data-structures/stack/index.d.ts +1 -0
  206. package/lib/types/data-structures/stack/index.js +1 -0
  207. package/lib/types/data-structures/stack/stack.d.ts +1 -0
  208. package/lib/types/data-structures/stack/stack.js +1 -0
  209. package/lib/types/data-structures/tree/index.d.ts +1 -0
  210. package/lib/types/data-structures/tree/index.js +1 -0
  211. package/lib/types/data-structures/tree/tree.d.ts +1 -0
  212. package/lib/types/data-structures/tree/tree.js +1 -0
  213. package/lib/types/data-structures/trie/index.d.ts +1 -0
  214. package/lib/types/data-structures/trie/index.js +1 -0
  215. package/lib/types/data-structures/trie/trie.d.ts +1 -0
  216. package/lib/types/data-structures/trie/trie.js +1 -0
  217. package/lib/types/helpers.d.ts +2 -0
  218. package/lib/utils/utils.d.ts +1 -0
  219. package/lib/utils/utils.js +6 -0
  220. package/package.json +6 -6
  221. package/src/data-structures/binary-tree/avl-tree.ts +42 -34
  222. package/src/data-structures/binary-tree/binary-indexed-tree.ts +264 -42
  223. package/src/data-structures/binary-tree/binary-tree.ts +267 -172
  224. package/src/data-structures/binary-tree/bst.ts +111 -60
  225. package/src/data-structures/binary-tree/tree-multiset.ts +47 -39
  226. package/src/types/data-structures/{avl-tree.ts → binary-tree/avl-tree.ts} +1 -1
  227. package/src/types/data-structures/binary-tree/binary-indexed-tree.ts +1 -0
  228. package/src/types/data-structures/{binary-tree.ts → binary-tree/binary-tree.ts} +1 -13
  229. package/src/types/data-structures/{bst.ts → binary-tree/bst.ts} +1 -1
  230. package/src/types/data-structures/binary-tree/index.ts +6 -0
  231. package/src/types/data-structures/{rb-tree.ts → binary-tree/rb-tree.ts} +2 -2
  232. package/src/types/data-structures/{tree-multiset.ts → binary-tree/tree-multiset.ts} +1 -1
  233. package/src/types/data-structures/graph/index.ts +3 -0
  234. package/src/types/data-structures/graph/undirected-graph.ts +1 -0
  235. package/src/types/data-structures/hash/coordinate-map.ts +1 -0
  236. package/src/types/data-structures/hash/coordinate-set.ts +1 -0
  237. package/src/types/data-structures/hash/hash-map.ts +1 -0
  238. package/src/types/data-structures/hash/hash-table.ts +1 -0
  239. package/src/types/data-structures/hash/tree-map.ts +1 -0
  240. package/src/types/data-structures/hash/tree-set.ts +1 -0
  241. package/src/types/data-structures/heap/heap.ts +1 -0
  242. package/src/types/data-structures/heap/index.ts +1 -0
  243. package/src/types/data-structures/heap/max-heap.ts +1 -0
  244. package/src/types/data-structures/heap/min-heap.ts +1 -0
  245. package/src/types/data-structures/index.ts +8 -14
  246. package/src/types/data-structures/linked-list/doubly-linked-list.ts +1 -0
  247. package/src/types/data-structures/linked-list/index.ts +2 -0
  248. package/src/types/data-structures/linked-list/singly-linked-list.ts +1 -0
  249. package/src/types/data-structures/linked-list/skip-linked-list.ts +1 -0
  250. package/src/types/data-structures/matrix/index.ts +1 -0
  251. package/src/types/data-structures/matrix/matrix.ts +1 -0
  252. package/src/types/data-structures/matrix/matrix2d.ts +1 -0
  253. package/src/types/data-structures/matrix/vector2d.ts +1 -0
  254. package/src/types/data-structures/priority-queue/index.ts +3 -0
  255. package/src/types/data-structures/priority-queue/max-priority-queue.ts +1 -0
  256. package/src/types/data-structures/priority-queue/min-priority-queue.ts +1 -0
  257. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
  258. package/src/types/data-structures/queue/deque.ts +1 -0
  259. package/src/types/data-structures/queue/index.ts +2 -0
  260. package/src/types/data-structures/queue/queue.ts +1 -0
  261. package/src/types/data-structures/stack/index.ts +1 -0
  262. package/src/types/data-structures/stack/stack.ts +1 -0
  263. package/src/types/data-structures/tree/index.ts +1 -0
  264. package/src/types/data-structures/tree/tree.ts +1 -0
  265. package/src/types/data-structures/trie/index.ts +1 -0
  266. package/src/types/data-structures/trie/trie.ts +1 -0
  267. package/src/types/helpers.ts +4 -1
  268. package/src/utils/utils.ts +7 -0
  269. package/test/config.js +4 -0
  270. package/test/types/index.js +29 -0
  271. package/test/types/utils/big-o.js +2 -0
  272. package/test/types/utils/index.js +29 -0
  273. package/test/unit/data-structures/binary-tree/binary-index-tree.test.ts +284 -0
  274. package/test/utils/big-o.js +212 -0
  275. package/test/utils/index.js +30 -0
  276. package/test/utils/number.js +14 -0
  277. package/umd/bundle.min.js +1 -1
  278. package/umd/bundle.min.js.map +1 -1
  279. package/dist/types/data-structures/abstract-graph.js.map +0 -1
  280. package/dist/types/data-structures/avl-tree.js.map +0 -1
  281. package/dist/types/data-structures/binary-tree.js.map +0 -1
  282. package/dist/types/data-structures/bst.js.map +0 -1
  283. package/dist/types/data-structures/directed-graph.js.map +0 -1
  284. package/dist/types/data-structures/doubly-linked-list.js.map +0 -1
  285. package/dist/types/data-structures/hash.js.map +0 -1
  286. package/dist/types/data-structures/heap.js.map +0 -1
  287. package/dist/types/data-structures/map-graph.js.map +0 -1
  288. package/dist/types/data-structures/navigator.js.map +0 -1
  289. package/dist/types/data-structures/rb-tree.js.map +0 -1
  290. package/dist/types/data-structures/segment-tree.js.map +0 -1
  291. package/dist/types/data-structures/singly-linked-list.js.map +0 -1
  292. package/dist/types/data-structures/tree-multiset.js.map +0 -1
  293. /package/dist/types/data-structures/{avl-tree.js → binary-tree/avl-tree.js} +0 -0
  294. /package/dist/types/data-structures/{doubly-linked-list.d.ts → binary-tree/binary-indexed-tree.d.ts} +0 -0
  295. /package/dist/types/data-structures/{binary-tree.js → binary-tree/binary-tree.js} +0 -0
  296. /package/dist/types/data-structures/{bst.js → binary-tree/bst.js} +0 -0
  297. /package/dist/types/data-structures/{rb-tree.js → binary-tree/rb-tree.js} +0 -0
  298. /package/dist/types/data-structures/{segment-tree.d.ts → binary-tree/segment-tree.d.ts} +0 -0
  299. /package/dist/types/data-structures/{segment-tree.js → binary-tree/segment-tree.js} +0 -0
  300. /package/dist/types/data-structures/{tree-multiset.js → binary-tree/tree-multiset.js} +0 -0
  301. /package/dist/types/data-structures/{abstract-graph.d.ts → graph/abstract-graph.d.ts} +0 -0
  302. /package/dist/types/data-structures/{abstract-graph.js → graph/abstract-graph.js} +0 -0
  303. /package/dist/types/data-structures/{directed-graph.d.ts → graph/directed-graph.d.ts} +0 -0
  304. /package/dist/types/data-structures/{directed-graph.js → graph/directed-graph.js} +0 -0
  305. /package/dist/types/data-structures/{map-graph.d.ts → graph/map-graph.d.ts} +0 -0
  306. /package/dist/types/data-structures/{map-graph.js → graph/map-graph.js} +0 -0
  307. /package/dist/types/data-structures/{heap.d.ts → graph/undirected-graph.d.ts} +0 -0
  308. /package/dist/types/data-structures/{singly-linked-list.d.ts → hash/coordinate-map.d.ts} +0 -0
  309. /package/{lib/types/data-structures/abstract-graph.js → dist/types/data-structures/hash/coordinate-set.d.ts} +0 -0
  310. /package/{lib/types/data-structures/avl-tree.js → dist/types/data-structures/hash/hash-map.d.ts} +0 -0
  311. /package/{lib/types/data-structures/doubly-linked-list.d.ts → dist/types/data-structures/hash/hash-table.d.ts} +0 -0
  312. /package/dist/types/data-structures/{hash.d.ts → hash/index.d.ts} +0 -0
  313. /package/{lib/types/data-structures/doubly-linked-list.js → dist/types/data-structures/hash/tree-map.d.ts} +0 -0
  314. /package/{lib/types/data-structures/hash.js → dist/types/data-structures/hash/tree-set.d.ts} +0 -0
  315. /package/{lib/types/data-structures → dist/types/data-structures/heap}/heap.d.ts +0 -0
  316. /package/dist/types/data-structures/{heap.js → heap/heap.js} +0 -0
  317. /package/{lib/types/data-structures/heap.js → dist/types/data-structures/heap/max-heap.d.ts} +0 -0
  318. /package/{lib/types/data-structures/map-graph.js → dist/types/data-structures/heap/min-heap.d.ts} +0 -0
  319. /package/{lib/types/data-structures/navigator.js → dist/types/data-structures/linked-list/doubly-linked-list.d.ts} +0 -0
  320. /package/dist/types/data-structures/{doubly-linked-list.js → linked-list/doubly-linked-list.js} +0 -0
  321. /package/{lib/types/data-structures → dist/types/data-structures/linked-list}/singly-linked-list.d.ts +0 -0
  322. /package/dist/types/data-structures/{singly-linked-list.js → linked-list/singly-linked-list.js} +0 -0
  323. /package/{lib/types/data-structures/segment-tree.js → dist/types/data-structures/linked-list/skip-linked-list.d.ts} +0 -0
  324. /package/{lib/types/data-structures/singly-linked-list.js → dist/types/data-structures/matrix/matrix.d.ts} +0 -0
  325. /package/{lib/types/data-structures/tree-multiset.js → dist/types/data-structures/matrix/matrix2d.d.ts} +0 -0
  326. /package/dist/types/data-structures/{navigator.d.ts → matrix/navigator.d.ts} +0 -0
  327. /package/dist/types/data-structures/{navigator.js → matrix/navigator.js} +0 -0
  328. /package/{src/types/data-structures/doubly-linked-list.ts → dist/types/data-structures/matrix/vector2d.d.ts} +0 -0
  329. /package/{src/types/data-structures/heap.ts → dist/types/data-structures/priority-queue/max-priority-queue.d.ts} +0 -0
  330. /package/{src/types/data-structures/singly-linked-list.ts → dist/types/data-structures/priority-queue/min-priority-queue.d.ts} +0 -0
  331. /package/lib/types/data-structures/{binary-tree.js → binary-tree/binary-tree.js} +0 -0
  332. /package/lib/types/data-structures/{bst.js → binary-tree/bst.js} +0 -0
  333. /package/lib/types/data-structures/{rb-tree.js → binary-tree/rb-tree.js} +0 -0
  334. /package/lib/types/data-structures/{segment-tree.d.ts → binary-tree/segment-tree.d.ts} +0 -0
  335. /package/lib/types/data-structures/{abstract-graph.d.ts → graph/abstract-graph.d.ts} +0 -0
  336. /package/lib/types/data-structures/{directed-graph.d.ts → graph/directed-graph.d.ts} +0 -0
  337. /package/lib/types/data-structures/{directed-graph.js → graph/directed-graph.js} +0 -0
  338. /package/lib/types/data-structures/{map-graph.d.ts → graph/map-graph.d.ts} +0 -0
  339. /package/lib/types/data-structures/{hash.d.ts → hash/index.d.ts} +0 -0
  340. /package/lib/types/data-structures/{navigator.d.ts → matrix/navigator.d.ts} +0 -0
  341. /package/src/types/data-structures/{segment-tree.ts → binary-tree/segment-tree.ts} +0 -0
  342. /package/src/types/data-structures/{abstract-graph.ts → graph/abstract-graph.ts} +0 -0
  343. /package/src/types/data-structures/{directed-graph.ts → graph/directed-graph.ts} +0 -0
  344. /package/src/types/data-structures/{map-graph.ts → graph/map-graph.ts} +0 -0
  345. /package/src/types/data-structures/{hash.ts → hash/index.ts} +0 -0
  346. /package/src/types/data-structures/{navigator.ts → matrix/navigator.ts} +0 -0
@@ -26,8 +26,10 @@ export class BSTNode<V = any, FAMILY extends BSTNode<V, FAMILY> = BSTNodeNested<
26
26
 
27
27
  export class BST<N extends BSTNode<N['val'], N> = BSTNode> extends BinaryTree<N> implements IBinaryTree<N> {
28
28
  /**
29
- * The constructor function initializes a binary search tree object with an optional comparator function.
30
- * @param {BSTOptions} [options] - An optional object that contains configuration options for the binary search tree.
29
+ * The constructor function initializes a binary search tree object with an optional comparator
30
+ * function.
31
+ * @param {BSTOptions} [options] - An optional object that contains configuration options for the
32
+ * binary search tree.
31
33
  */
32
34
  constructor(options?: BSTOptions) {
33
35
  super(options);
@@ -41,10 +43,10 @@ export class BST<N extends BSTNode<N['val'], N> = BSTNode> extends BinaryTree<N>
41
43
 
42
44
  /**
43
45
  * The function creates a new binary search tree node with the given key and value.
44
- * @param {BinaryTreeNodeKey} key - The `key` parameter is the identifier for the binary tree node. It is used to uniquely
45
- * identify each node in the binary tree.
46
- * @param [val] - The `val` parameter is an optional value that can be assigned to the node. It represents the value
47
- * that will be stored in the node.
46
+ * @param {BinaryTreeNodeKey} key - The key parameter is the key value that will be associated with
47
+ * the new node. It is used to determine the position of the node in the binary search tree.
48
+ * @param [val] - The parameter `val` is an optional value that can be assigned to the node. It
49
+ * represents the value associated with the node in a binary search tree.
48
50
  * @returns a new instance of the BSTNode class with the specified key and value.
49
51
  */
50
52
  override createNode(key: BinaryTreeNodeKey, val?: N['val']): N {
@@ -52,13 +54,14 @@ export class BST<N extends BSTNode<N['val'], N> = BSTNode> extends BinaryTree<N>
52
54
  }
53
55
 
54
56
  /**
55
- * The `add` function adds a new node to a binary search tree, either by creating a new node or by updating an existing
56
- * node with the same ID.
57
- * @param {BinaryTreeNodeKey | N | null} keyOrNode - The `keyOrNode` parameter can be either a `BinaryTreeNodeKey` or a `N`
58
- * (which represents a binary tree node) or `null`.
59
- * @param [val] - The `val` parameter is an optional value that can be assigned to the `val` property of the new node
60
- * being added to the binary search tree.
61
- * @returns The function `add` returns the inserted node (`inserted`) which can be of type `N`, `null`, or `undefined`.
57
+ * The `add` function in a binary search tree class inserts a new node with a given key and value
58
+ * into the tree.
59
+ * @param {BinaryTreeNodeKey | N | null} keyOrNode - The `keyOrNode` parameter can be either a
60
+ * `BinaryTreeNodeKey` (which can be a number or a string), a `BSTNode` object, or `null`.
61
+ * @param [val] - The `val` parameter is the value to be assigned to the new node being added to the
62
+ * binary search tree.
63
+ * @returns the inserted node (N) if it was successfully added to the binary search tree. If the node
64
+ * was not added or if the parameters were invalid, it returns null or undefined.
62
65
  */
63
66
  override add(keyOrNode: BinaryTreeNodeKey | N | null, val?: N['val']): N | null | undefined {
64
67
  // TODO support node as a parameter
@@ -127,16 +130,19 @@ export class BST<N extends BSTNode<N['val'], N> = BSTNode> extends BinaryTree<N>
127
130
  }
128
131
 
129
132
  /**
130
- * The `addMany` function overrides the base class method to add multiple nodes to a binary search tree in a balanced
131
- * manner.
132
- * @param {[BinaryTreeNodeKey | N , N['val']][]} keysOrNodes - The `keysOrNodes` parameter in the `addMany` function is an array of
133
- * `BinaryTreeNodeKey` or `N` (node) objects, or `null` values. It represents the nodes or node IDs that need to be added
134
- * to the binary search tree.
133
+ * The `addMany` function is used to efficiently add multiple nodes to a binary search tree while
134
+ * maintaining balance.
135
+ * @param {[BinaryTreeNodeKey | N, N['val']][]} arr - The `arr` parameter in the `addMany` function
136
+ * represents an array of keys or nodes that need to be added to the binary search tree. It can be an
137
+ * array of `BinaryTreeNodeKey` or `N` (which represents the node type in the binary search tree) or
138
+ * `null
135
139
  * @param {N['val'][]} data - The values of tree nodes
136
140
  * @param {boolean} isBalanceAdd - If true the nodes will be balance inserted in binary search method.
137
- * @param iterationType - The `iterationType` parameter is an optional parameter that specifies whether to use a
138
- * @returns The function `addMany` returns an array of `N`, `null`, or `undefined` values.
141
+ * @param iterationType - The `iterationType` parameter determines the type of iteration to be used.
142
+ * It can have two possible values:
143
+ * @returns The `addMany` function returns an array of `N`, `null`, or `undefined` values.
139
144
  */
145
+
140
146
  override addMany(
141
147
  keysOrNodes: (BinaryTreeNodeKey | null)[] | (N | null)[],
142
148
  data?: N['val'][],
@@ -211,22 +217,46 @@ export class BST<N extends BSTNode<N['val'], N> = BSTNode> extends BinaryTree<N>
211
217
  }
212
218
 
213
219
  /**
214
- * The function returns the first node in a binary tree that matches the given property name and value.
215
- * @param {BinaryTreeNodeKey | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeKey` or a
216
- * generic type `N`. It represents the property of the binary tree node that you want to search for.
217
- * @param callback - The `callback` parameter is a function that takes a node as a parameter and returns a value.
218
- * specifies the property name to use for searching the binary tree nodes. If not provided, it defaults to `'key'`.
219
- * @returns The method is returning either a BinaryTreeNodeKey or N (generic type) or null.
220
+ * The function returns the first node in the binary tree that matches the given node property and
221
+ * callback.
222
+ * @param {BinaryTreeNodeKey | N} nodeProperty - The `nodeProperty` parameter is used to specify the
223
+ * property of the binary tree node that you want to search for. It can be either a specific key
224
+ * value (`BinaryTreeNodeKey`) or a custom callback function (`MapCallback<N>`) that determines
225
+ * whether a node matches the desired property.
226
+ * @param callback - The `callback` parameter is a function that is used to determine whether a node
227
+ * matches the desired property. It takes a node as input and returns a boolean value indicating
228
+ * whether the node matches the property or not. If no callback function is provided, the default
229
+ * callback function `_defaultCallbackByKey` is used
230
+ * @param beginRoot - The `beginRoot` parameter is the starting point for the search. It specifies
231
+ * the root node from which the search should begin.
232
+ * @param iterationType - The `iterationType` parameter is used to specify the type of iteration to
233
+ * be performed when searching for nodes in the binary tree. It can have one of the following values:
234
+ * @returns either the first node that matches the given nodeProperty and callback, or null if no
235
+ * matching node is found.
220
236
  */
221
- override get(nodeProperty: BinaryTreeNodeKey | N, callback: MapCallback<N> = this._defaultCallbackByKey): N | null {
222
- return this.getNodes(nodeProperty, callback, true)[0] ?? null;
237
+ override get(
238
+ nodeProperty: BinaryTreeNodeKey | N,
239
+ callback: MapCallback<N> = this._defaultCallbackByKey,
240
+ beginRoot = this.root,
241
+ iterationType = this.iterationType
242
+ ): N | null {
243
+ return this.getNodes(nodeProperty, callback, true, beginRoot, iterationType)[0] ?? null;
223
244
  }
224
245
 
225
246
  /**
226
- * lastKey returns the last key in a binary tree. If the binary tree is empty, it returns 0.
227
- * @param beginRoot - The `beginRoot` parameter is an optional parameter that specifies the root node from which to begin
228
- * the search for the last key.
229
- * @param iterationType - The `iterationType` parameter is an optional parameter that specifies whether to use a recursive or iterative approach to search for the last key.
247
+ * The function `lastKey` returns the key of the rightmost node if the comparison result is less
248
+ * than, the key of the leftmost node if the comparison result is greater than, and the key of the
249
+ * rightmost node otherwise.
250
+ * @param {N | null} beginRoot - The `beginRoot` parameter is the starting point for finding the last
251
+ * key in a binary tree. It represents the root node of the subtree from which the search for the
252
+ * last key should begin. If no specific `beginRoot` is provided, the search will start from the root
253
+ * of the entire binary
254
+ * @param iterationType - The `iterationType` parameter is used to specify the type of iteration to
255
+ * be performed when finding the last key. It determines whether the iteration should be performed in
256
+ * pre-order, in-order, or post-order.
257
+ * @returns the key of the rightmost node in the binary tree if the comparison result is less than,
258
+ * the key of the leftmost node if the comparison result is greater than, and the key of the
259
+ * rightmost node otherwise. If no node is found, it returns 0.
230
260
  */
231
261
  lastKey(beginRoot: N | null = this.root, iterationType = this.iterationType): BinaryTreeNodeKey {
232
262
  if (this._compare(0, 1) === CP.lt) return this.getRightMost(beginRoot, iterationType)?.key ?? 0;
@@ -235,17 +265,25 @@ export class BST<N extends BSTNode<N['val'], N> = BSTNode> extends BinaryTree<N>
235
265
  }
236
266
 
237
267
  /**
238
- * The function `getNodes` returns an array of nodes in a binary tree that match a given property value.
239
- * @param {BinaryTreeNodeKey | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeKey` or an
240
- * `N` type. It represents the property of the binary tree node that you want to compare with.
241
- * @param callback - The `callback` parameter is a function that takes a node as a parameter and returns a value.
242
- * specifies the property name to use for comparison. If not provided, it defaults to `'key'`.
243
- * @param {boolean} [onlyOne] - The `onlyOne` parameter is an optional boolean parameter that determines whether to
244
- * return only one node that matches the given `nodeProperty` or all nodes that match the `nodeProperty`. If `onlyOne`
245
- * is set to `true`, the function will return an array with only one node (if
246
- * @param beginRoot - The `beginRoot` parameter is an optional parameter that specifies the root node from which to
247
- * @param iterationType
248
- * @returns an array of nodes (type N).
268
+ * The function `getNodes` retrieves nodes from a binary tree based on a given node property or key,
269
+ * using either recursive or iterative traversal.
270
+ * @param {BinaryTreeNodeKey | N} nodeProperty - The `nodeProperty` parameter represents the property
271
+ * of the binary tree node that you want to search for. It can be either a `BinaryTreeNodeKey` or a
272
+ * generic type `N`.
273
+ * @param callback - The `callback` parameter is a function that takes a node as input and returns a
274
+ * value. This value is compared with the `nodeProperty` parameter to determine if the node should be
275
+ * included in the result. The default value for `callback` is `this._defaultCallbackByKey`, which is
276
+ * a
277
+ * @param [onlyOne=false] - A boolean value indicating whether to stop the traversal after finding
278
+ * the first node that matches the nodeProperty. If set to true, the function will return an array
279
+ * containing only that node. If set to false (default), the function will continue the traversal and
280
+ * return an array containing all nodes that match the node
281
+ * @param {N | null} beginRoot - The `beginRoot` parameter is the starting node for the traversal. It
282
+ * specifies the root node of the binary tree from which the traversal should begin. If `beginRoot`
283
+ * is `null`, an empty array will be returned.
284
+ * @param iterationType - The `iterationType` parameter determines the type of iteration used to
285
+ * traverse the binary tree. It can have one of the following values:
286
+ * @returns an array of nodes (N[]).
249
287
  */
250
288
  override getNodes(
251
289
  nodeProperty: BinaryTreeNodeKey | N,
@@ -305,13 +343,21 @@ export class BST<N extends BSTNode<N['val'], N> = BSTNode> extends BinaryTree<N>
305
343
  // --- start additional functions
306
344
 
307
345
  /**
308
- * The `lesserOrGreaterTraverse` function adds a delta value to the specified property of all nodes in a binary tree that
309
- * have a greater value than a given node.
310
- * @param callback - The `callback` parameter is a function that takes a node as a parameter and returns a value.
311
- * represents the node in the binary tree to which the delta value will be added.
312
- * @param lesserOrGreater - The `lesserOrGreater` parameter is an optional parameter that specifies whether the delta
313
- * @param targetNode - The `targetNode` parameter is an optional parameter that specifies the node in the binary tree
314
- * @param iterationType - The `iterationType` parameter is an optional parameter that specifies whether to use a
346
+ * The `lesserOrGreaterTraverse` function traverses a binary tree and applies a callback function to
347
+ * nodes that have a key value lesser or greater than a target key value.
348
+ * @param callback - The `callback` parameter is a function that will be called for each node that
349
+ * meets the condition specified by the `lesserOrGreater` parameter. It takes a node as an argument
350
+ * and returns a value.
351
+ * @param {CP} lesserOrGreater - The `lesserOrGreater` parameter is used to determine whether to
352
+ * traverse nodes that are lesser than, greater than, or equal to the `targetNode`. It can take one
353
+ * of the following values:
354
+ * @param {N | BinaryTreeNodeKey | null} targetNode - The `targetNode` parameter in the
355
+ * `lesserOrGreaterTraverse` function is used to specify the node from which the traversal should
356
+ * start. It can be either a reference to a specific node (`N`), the key of a node
357
+ * (`BinaryTreeNodeKey`), or `null` to
358
+ * @param iterationType - The `iterationType` parameter determines whether the traversal should be
359
+ * done recursively or iteratively. It can have two possible values:
360
+ * @returns The function `lesserOrGreaterTraverse` returns an array of `MapCallbackReturn<N>`.
315
361
  */
316
362
  lesserOrGreaterTraverse(
317
363
  callback: MapCallback<N> = this._defaultCallbackByKey,
@@ -364,9 +410,12 @@ export class BST<N extends BSTNode<N['val'], N> = BSTNode> extends BinaryTree<N>
364
410
  */
365
411
 
366
412
  /**
367
- * The `perfectlyBalance` function takes a binary tree, performs a depth-first search to sort the nodes, and then
368
- * constructs a balanced binary search tree using either a recursive or iterative approach.
369
- * @returns The function `perfectlyBalance()` returns a boolean value.
413
+ * The `perfectlyBalance` function balances a binary search tree by adding nodes in a way that
414
+ * ensures the tree is perfectly balanced.
415
+ * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
416
+ * type of iteration to use when building a balanced binary search tree. It can have two possible
417
+ * values:
418
+ * @returns The function `perfectlyBalance` returns a boolean value.
370
419
  */
371
420
  perfectlyBalance(iterationType = this.iterationType): boolean {
372
421
  const sorted = this.dfs(node => node, 'in'),
@@ -406,7 +455,9 @@ export class BST<N extends BSTNode<N['val'], N> = BSTNode> extends BinaryTree<N>
406
455
  }
407
456
 
408
457
  /**
409
- * The function `isAVLBalanced` checks if a binary tree is balanced according to the AVL tree property.
458
+ * The function checks if a binary tree is AVL balanced using either recursive or iterative approach.
459
+ * @param iterationType - The `iterationType` parameter is used to determine the method of iteration
460
+ * to check if the AVL tree is balanced. It can have two possible values:
410
461
  * @returns a boolean value.
411
462
  */
412
463
  isAVLBalanced(iterationType = this.iterationType): boolean {
@@ -456,12 +507,12 @@ export class BST<N extends BSTNode<N['val'], N> = BSTNode> extends BinaryTree<N>
456
507
  protected _comparator: BSTComparator = (a, b) => a - b;
457
508
 
458
509
  /**
459
- * The function compares two binary tree node IDs using a comparator function and returns whether the first ID is
460
- * greater than, less than, or equal to the second ID.
461
- * @param {BinaryTreeNodeKey} a - "a" is a BinaryTreeNodeKey, which represents the identifier of a binary tree node.
462
- * @param {BinaryTreeNodeKey} b - The parameter "b" in the above code refers to a BinaryTreeNodeKey.
463
- * @returns a value of type CP (ComparisonResult). The possible return values are CP.gt (greater than), CP.lt (less
464
- * than), or CP.eq (equal).
510
+ * The function compares two values using a comparator function and returns whether the first value
511
+ * is greater than, less than, or equal to the second value.
512
+ * @param {BinaryTreeNodeKey} a - The parameter "a" is of type BinaryTreeNodeKey.
513
+ * @param {BinaryTreeNodeKey} b - The parameter "b" in the above code represents a BinaryTreeNodeKey.
514
+ * @returns a value of type CP (ComparisonResult). The possible return values are CP.gt (greater
515
+ * than), CP.lt (less than), or CP.eq (equal).
465
516
  */
466
517
  protected _compare(a: BinaryTreeNodeKey, b: BinaryTreeNodeKey): CP {
467
518
  const compared = this._comparator(a, b);
@@ -69,11 +69,11 @@ export class TreeMultiset<N extends TreeMultisetNode<N['val'], N> = TreeMultiset
69
69
  }
70
70
 
71
71
  /**
72
- * The function swaps the location of two nodes in a tree data structure.
73
- * @param {N} srcNode - The source node that we want to _swap with the destination node.
74
- * @param {N} destNode - The `destNode` parameter represents the destination node where the values from `srcNode` will
75
- * be swapped with.
76
- * @returns the `destNode` after swapping its values with the `srcNode`.
72
+ * The function swaps the values of two nodes in a binary tree.
73
+ * @param {N} srcNode - The source node that needs to be swapped with the destination node.
74
+ * @param {N} destNode - The `destNode` parameter represents the destination node where the values
75
+ * from `srcNode` will be swapped into.
76
+ * @returns The method is returning the `destNode` after swapping its properties with the `srcNode`.
77
77
  */
78
78
  protected override _swap(srcNode: N, destNode: N): N {
79
79
  const {key, val, count, height} = destNode;
@@ -96,14 +96,17 @@ export class TreeMultiset<N extends TreeMultisetNode<N['val'], N> = TreeMultiset
96
96
  }
97
97
 
98
98
  /**
99
- * The `add` function adds a new node to a binary search tree, maintaining the tree's properties and balancing if
100
- * necessary.
101
- * @param {BinaryTreeNodeKey | N} keyOrNode - The `keyOrNode` parameter can be either a `BinaryTreeNodeKey` or a `N` (which
102
- * represents a `BinaryTreeNode`).
103
- * @param [val] - The `val` parameter represents the value to be added to the binary tree node.
104
- * @param {number} [count] - The `count` parameter is an optional parameter that specifies the number of times the
105
- * value should be added to the binary tree. If the `count` parameter is not provided, it defaults to 1.
106
- * @returns The method `add` returns either the inserted node (`N`), `null`, or `undefined`.
99
+ * The `add` function adds a new node to a binary search tree, updating the count if the key already
100
+ * exists, and balancing the tree if necessary.
101
+ * @param {BinaryTreeNodeKey | N | null} keyOrNode - The `keyOrNode` parameter can be either a
102
+ * `BinaryTreeNodeKey` (which represents the key of the node to be added), a `N` (which represents a
103
+ * node to be added), or `null` (which represents a null node).
104
+ * @param [val] - The `val` parameter represents the value associated with the key that is being
105
+ * added to the binary tree.
106
+ * @param [count=1] - The `count` parameter represents the number of occurrences of the key/value
107
+ * pair that will be added to the binary tree. It has a default value of 1, which means that if no
108
+ * count is specified, the default count will be 1.
109
+ * @returns The function `add` returns a value of type `N | null | undefined`.
107
110
  */
108
111
  override add(keyOrNode: BinaryTreeNodeKey | N | null, val?: N['val'], count = 1): N | null | undefined {
109
112
  let inserted: N | null | undefined = undefined,
@@ -174,13 +177,12 @@ export class TreeMultiset<N extends TreeMultisetNode<N['val'], N> = TreeMultiset
174
177
  }
175
178
 
176
179
  /**
177
- * The function adds a new node to a binary tree if there is an available slot on the left or right side of the parent
178
- * node.
179
- * @param {N | null} newNode - The `newNode` parameter represents the node that needs to be added to the tree. It can
180
- * be either a node object (`N`) or `null`.
181
- * @param {N} parent - The `parent` parameter represents the parent node to which the new node will be added as a
182
- * child.
183
- * @returns The method returns either the `parent.left`, `parent.right`, or `undefined`.
180
+ * The function adds a new node to a binary tree if there is an available slot in the parent node.
181
+ * @param {N | null} newNode - The `newNode` parameter represents the node that needs to be added to
182
+ * the tree. It can be either a node object (`N`) or `null`.
183
+ * @param {N} parent - The `parent` parameter represents the parent node to which the new node will
184
+ * be added as a child.
185
+ * @returns The method `_addTo` returns either the `parent.left`, `parent.right`, or `undefined`.
184
186
  */
185
187
  override _addTo(newNode: N | null, parent: N): N | null | undefined {
186
188
  if (parent) {
@@ -208,13 +210,13 @@ export class TreeMultiset<N extends TreeMultisetNode<N['val'], N> = TreeMultiset
208
210
  }
209
211
 
210
212
  /**
211
- * The `addMany` function takes an array of node IDs or nodes and adds them to the tree multiset, returning an array of
212
- * the inserted nodes.
213
- * @param {(BinaryTreeNodeKey | null)[] | (N | null)[]} keysOrNodes - An array of BinaryTreeNodeKey or BinaryTreeNode
214
- * objects, or null values.
215
- * @param {N['val'][]} [data] - The `data` parameter is an optional array of values (`N['val'][]`) that corresponds to
216
- * the nodes being added. It is used when adding nodes using the `keyOrNode` and `data` arguments in the `this.add()`
217
- * method. If provided, the `data` array should
213
+ * The `addMany` function adds multiple keys or nodes to a TreeMultiset and returns an array of the
214
+ * inserted nodes.
215
+ * @param {(BinaryTreeNodeKey | null)[] | (N | null)[]} keysOrNodes - An array of keys or nodes to be
216
+ * added to the multiset. Each element can be either a BinaryTreeNodeKey or a TreeMultisetNode.
217
+ * @param {N['val'][]} [data] - The `data` parameter is an optional array of values that correspond
218
+ * to the keys or nodes being added to the multiset. It is used to associate additional data with
219
+ * each key or node.
218
220
  * @returns The function `addMany` returns an array of `N`, `null`, or `undefined` values.
219
221
  */
220
222
  override addMany(
@@ -242,9 +244,12 @@ export class TreeMultiset<N extends TreeMultisetNode<N['val'], N> = TreeMultiset
242
244
  }
243
245
 
244
246
  /**
245
- * The `perfectlyBalance` function takes a binary tree, performs a depth-first search to sort the nodes, and then
246
- * constructs a balanced binary search tree using either a recursive or iterative approach.
247
- * @returns The function `perfectlyBalance()` returns a boolean value.
247
+ * The `perfectlyBalance` function in TypeScript takes a sorted array of nodes and builds a balanced
248
+ * binary search tree using either a recursive or iterative approach.
249
+ * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
250
+ * type of iteration to use when building a balanced binary search tree. It can have two possible
251
+ * values:
252
+ * @returns a boolean value.
248
253
  */
249
254
  override perfectlyBalance(iterationType = this.iterationType): boolean {
250
255
  const sorted = this.dfs(node => node, 'in'),
@@ -285,13 +290,16 @@ export class TreeMultiset<N extends TreeMultisetNode<N['val'], N> = TreeMultiset
285
290
  }
286
291
 
287
292
  /**
288
- * The `delete` function removes a node from a binary search tree and returns the deleted node along with the parent
289
- * node that needs to be balanced.
290
- * @param {N | BinaryTreeNodeKey | null} nodeOrKey - The `nodeOrKey` parameter can be one of the following:
291
- * @param {boolean} [ignoreCount] - The `ignoreCount` parameter is an optional boolean parameter that determines
292
- * whether to ignore the count of the node being removed. If `ignoreCount` is set to `true`, the count of the node will
293
- * not be taken into account when removing it. If `ignoreCount` is set to `false
294
- * @returns The function `delete` returns an array of `BinaryTreeDeletedResult<N>` objects.
293
+ * The `delete` function in a binary search tree deletes a node from the tree and returns the deleted
294
+ * node along with the parent node that needs to be balanced.
295
+ * @param {N | BinaryTreeNodeKey} nodeOrKey - The `nodeOrKey` parameter can be either a node object
296
+ * (`N`) or a key value (`BinaryTreeNodeKey`). It represents the node or key that needs to be deleted
297
+ * from the binary tree.
298
+ * @param [ignoreCount=false] - A boolean flag indicating whether to ignore the count of the node
299
+ * being deleted. If set to true, the count of the node will not be considered and the node will be
300
+ * deleted regardless of its count. If set to false (default), the count of the node will be
301
+ * decremented by 1 and
302
+ * @returns The method `delete` returns an array of `BinaryTreeDeletedResult<N>` objects.
295
303
  */
296
304
  override delete(nodeOrKey: N | BinaryTreeNodeKey, ignoreCount = false): BinaryTreeDeletedResult<N>[] {
297
305
  const bstDeletedResult: BinaryTreeDeletedResult<N>[] = [];
@@ -350,7 +358,7 @@ export class TreeMultiset<N extends TreeMultisetNode<N['val'], N> = TreeMultiset
350
358
  }
351
359
 
352
360
  /**
353
- * The clear() function clears the data and sets the count to 0.
361
+ * The clear() function clears the contents of a data structure and sets the count to zero.
354
362
  */
355
363
  clear() {
356
364
  super.clear();
@@ -358,7 +366,7 @@ export class TreeMultiset<N extends TreeMultisetNode<N['val'], N> = TreeMultiset
358
366
  }
359
367
 
360
368
  /**
361
- * The function "_setCount" is used to set the value of the "_count" property.
369
+ * The function sets the value of the "_count" property.
362
370
  * @param {number} v - number
363
371
  */
364
372
  protected _setCount(v: number) {
@@ -1,4 +1,4 @@
1
- import {AVLTreeNode} from '../../data-structures';
1
+ import {AVLTreeNode} from '../../../data-structures';
2
2
  import {BSTOptions} from './bst';
3
3
 
4
4
  export type AVLTreeNodeNested<T> = AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -1,4 +1,4 @@
1
- import {BinaryTreeNode} from '../../data-structures/binary-tree';
1
+ import {BinaryTreeNode} from '../../../data-structures';
2
2
 
3
3
  /**
4
4
  * Enum representing different loop types.
@@ -22,26 +22,14 @@ export enum FamilyPosition {
22
22
  MAL_NODE = 'MAL_NODE'
23
23
  }
24
24
 
25
- export type BinaryTreeNodePropertyName = 'key' | 'val';
26
-
27
- export type NodeOrPropertyName = 'node' | BinaryTreeNodePropertyName;
28
-
29
25
  export type BinaryTreeNodeKey = number;
30
26
 
31
27
  export type BFSCallback<N> = (node: N, level?: number) => any;
32
28
 
33
29
  export type BFSCallbackReturn<N> = ReturnType<BFSCallback<N>>;
34
30
 
35
- export type BinaryTreeNodeProperty<N extends BinaryTreeNode<N['val'], N>> =
36
- | N['val']
37
- | N
38
- | number
39
- | BinaryTreeNodeKey;
40
31
  export type BinaryTreeDeletedResult<N> = { deleted: N | null | undefined; needBalanced: N | null };
41
32
 
42
- export type BinaryTreeNodeProperties<N extends BinaryTreeNode<N['val'], N>> =
43
- BinaryTreeNodeProperty<N>[];
44
-
45
33
  export type BinaryTreeNodeNested<T> = BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
46
34
 
47
35
  export type BinaryTreeOptions = { iterationType?: IterationType }
@@ -1,4 +1,4 @@
1
- import {BSTNode} from '../../data-structures/binary-tree';
1
+ import {BSTNode} from '../../../data-structures';
2
2
  import type {BinaryTreeNodeKey, BinaryTreeOptions} from './binary-tree';
3
3
 
4
4
  export type BSTComparator = (a: BinaryTreeNodeKey, b: BinaryTreeNodeKey) => number;
@@ -0,0 +1,6 @@
1
+ export * from './binary-tree';
2
+ export * from './bst';
3
+ export * from './avl-tree';
4
+ export * from './segment-tree';
5
+ export * from './tree-multiset';
6
+ export * from './rb-tree';
@@ -1,8 +1,8 @@
1
1
  import {BinaryTreeOptions} from './binary-tree';
2
- import {RBTreeNode} from '../../data-structures/binary-tree';
2
+ import {RBTreeNode} from '../../../data-structures';
3
3
 
4
4
  export enum RBColor { RED = 'RED', BLACK = 'BLACK'}
5
5
 
6
6
  export type RBTreeNodeNested<T> = RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
7
7
 
8
- export type RBTreeOptions = BinaryTreeOptions & {}
8
+ export type RBTreeOptions = BinaryTreeOptions & {}
@@ -1,4 +1,4 @@
1
- import {TreeMultisetNode} from '../../data-structures/binary-tree';
1
+ import {TreeMultisetNode} from '../../../data-structures';
2
2
  import {AVLTreeOptions} from './avl-tree';
3
3
 
4
4
  export type TreeMultisetNodeNested<T> = TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -0,0 +1,3 @@
1
+ export * from './abstract-graph';
2
+ export * from './map-graph';
3
+ export * from './directed-graph';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from './heap';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,17 +1,11 @@
1
1
  export * from './binary-tree';
2
- export * from './bst';
3
- export * from './avl-tree';
4
- export * from './segment-tree';
5
- export * from './tree-multiset';
6
- export * from './abstract-graph';
7
- export * from './map-graph';
8
- export * from './rb-tree';
9
- export * from './directed-graph';
2
+ export * from './graph';
3
+ export * from './linked-list';
10
4
  export * from './heap';
11
- export * from './singly-linked-list';
12
- export * from './doubly-linked-list';
13
- export * from './navigator';
5
+ export * from './matrix';
14
6
  export * from './hash';
15
-
16
- export type MapCallback<N> = (node: N) => any;
17
- export type MapCallbackReturn<N> = ReturnType<MapCallback<N>>;
7
+ export * from './priority-queue';
8
+ export * from './queue';
9
+ export * from './stack';
10
+ export * from './tree';
11
+ export * from './trie';
@@ -0,0 +1,2 @@
1
+ export * from './singly-linked-list';
2
+ export * from './doubly-linked-list';
@@ -0,0 +1 @@
1
+ export * from './navigator';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export * from './priority-queue';
2
+ export * from './min-priority-queue';
3
+ export * from './max-priority-queue';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './queue';
2
+ export * from './deque';