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
@@ -11,30 +11,47 @@ exports.BinaryTree = exports.BinaryTreeNode = void 0;
11
11
  const types_1 = require("../../types");
12
12
  const utils_1 = require("../../utils");
13
13
  const queue_1 = require("../queue");
14
+ /**
15
+ * Represents a node in a binary tree.
16
+ * @template V - The type of data stored in the node.
17
+ * @template FAMILY - The type of the family relationship in the binary tree.
18
+ */
14
19
  class BinaryTreeNode {
15
20
  /**
16
- * The constructor function initializes a BinaryTreeNode object with a key and an optional value.
17
- * @param {BinaryTreeNodeKey} key - The `key` parameter is of type `BinaryTreeNodeKey` and represents the unique identifier
18
- * of the binary tree node. It is used to distinguish one node from another in the binary tree.
19
- * @param {V} [val] - The "val" parameter is an optional parameter of type V. It represents the value that will be
20
- * stored in the binary tree node. If no value is provided, it will be set to undefined.
21
+ * Creates a new instance of BinaryTreeNode.
22
+ * @param {BinaryTreeNodeKey} key - The key associated with the node.
23
+ * @param {V} val - The value stored in the node.
21
24
  */
22
25
  constructor(key, val) {
23
26
  this.key = key;
24
27
  this.val = val;
25
28
  }
29
+ /**
30
+ * Get the left child node.
31
+ */
26
32
  get left() {
27
33
  return this._left;
28
34
  }
35
+ /**
36
+ * Set the left child node.
37
+ * @param {FAMILY | null | undefined} v - The left child node.
38
+ */
29
39
  set left(v) {
30
40
  if (v) {
31
41
  v.parent = this;
32
42
  }
33
43
  this._left = v;
34
44
  }
45
+ /**
46
+ * Get the right child node.
47
+ */
35
48
  get right() {
36
49
  return this._right;
37
50
  }
51
+ /**
52
+ * Set the right child node.
53
+ * @param {FAMILY | null | undefined} v - The right child node.
54
+ */
38
55
  set right(v) {
39
56
  if (v) {
40
57
  v.parent = this;
@@ -42,8 +59,8 @@ class BinaryTreeNode {
42
59
  this._right = v;
43
60
  }
44
61
  /**
45
- * The function determines the position of a node in a family tree structure.
46
- * @returns a value of type `FamilyPosition`.
62
+ * Get the position of the node within its family.
63
+ * @returns {FamilyPosition} - The family position of the node.
47
64
  */
48
65
  get familyPosition() {
49
66
  const that = this;
@@ -79,15 +96,16 @@ class BinaryTreeNode {
79
96
  }
80
97
  }
81
98
  exports.BinaryTreeNode = BinaryTreeNode;
99
+ /**
100
+ * Represents a binary tree data structure.
101
+ * @template N - The type of the binary tree's nodes.
102
+ */
82
103
  class BinaryTree {
83
104
  /**
84
- * This is a constructor function for a binary tree class that takes an optional options parameter.
85
- * @param {BinaryTreeOptions} [options] - The `options` parameter is an optional object that can be passed to the
86
- * constructor of the `BinaryTree` class. It allows you to customize the behavior of the binary tree by providing
87
- * different configuration options.
105
+ * Creates a new instance of BinaryTree.
106
+ * @param {BinaryTreeOptions} [options] - The options for the binary tree.
88
107
  */
89
108
  constructor(options) {
90
- // TODO placeholder node may need redesigned
91
109
  this._root = null;
92
110
  this._size = 0;
93
111
  this._loopType = types_1.IterationType.ITERATIVE;
@@ -98,34 +116,44 @@ class BinaryTree {
98
116
  }
99
117
  }
100
118
  /**
101
- * The function creates a new binary tree node with an optional value.
102
- * @param {BinaryTreeNodeKey} key - The `key` parameter is the identifier for the binary tree node. It is of type
103
- * `BinaryTreeNodeKey`, which represents the unique identifier for each node in the binary tree.
104
- * @param [val] - The `val` parameter is an optional value that can be assigned to the node. It represents the value
105
- * stored in the node.
106
- * @returns a new instance of a BinaryTreeNode with the specified key and value.
119
+ * Creates a new instance of BinaryTreeNode with the given key and value.
120
+ * @param {BinaryTreeNodeKey} key - The key for the new node.
121
+ * @param {N['val']} val - The value for the new node.
122
+ * @returns {N} - The newly created BinaryTreeNode.
107
123
  */
108
124
  createNode(key, val) {
109
125
  return new BinaryTreeNode(key, val);
110
126
  }
127
+ /**
128
+ * Get the root node of the binary tree.
129
+ */
111
130
  get root() {
112
131
  return this._root;
113
132
  }
133
+ /**
134
+ * Get the number of nodes in the binary tree.
135
+ */
114
136
  get size() {
115
137
  return this._size;
116
138
  }
139
+ /**
140
+ * Get the iteration type used in the binary tree.
141
+ */
117
142
  get iterationType() {
118
143
  return this._loopType;
119
144
  }
145
+ /**
146
+ * Set the iteration type for the binary tree.
147
+ * @param {IterationType} v - The new iteration type to set.
148
+ */
120
149
  set iterationType(v) {
121
150
  this._loopType = v;
122
151
  }
123
152
  /**
124
- * The `_swap` function swaps the location of two nodes in a binary tree.
125
- * @param {N} srcNode - The source node that you want to _swap with the destination node.
126
- * @param {N} destNode - The `destNode` parameter represents the destination node where the values from `srcNode` will
127
- * be swapped to.
128
- * @returns The `destNode` is being returned.
153
+ * Swap the data of two nodes in the binary tree.
154
+ * @param {N} srcNode - The source node to swap.
155
+ * @param {N} destNode - The destination node to swap.
156
+ * @returns {N} - The destination node after the swap.
129
157
  */
130
158
  _swap(srcNode, destNode) {
131
159
  const { key, val } = destNode;
@@ -139,31 +167,24 @@ class BinaryTree {
139
167
  return destNode;
140
168
  }
141
169
  /**
142
- * The clear() function resets the root, size, and maxKey properties to their initial values.
170
+ * Clear the binary tree, removing all nodes.
143
171
  */
144
172
  clear() {
145
173
  this._root = null;
146
174
  this._size = 0;
147
175
  }
148
176
  /**
149
- * The function checks if the size of an object is equal to zero and returns a boolean value.
150
- * @returns A boolean value indicating whether the size of the object is 0 or not.
177
+ * Check if the binary tree is empty.
178
+ * @returns {boolean} - True if the binary tree is empty, false otherwise.
151
179
  */
152
180
  isEmpty() {
153
181
  return this.size === 0;
154
182
  }
155
183
  /**
156
- * When all leaf nodes are null, it will no longer be possible to add new entity nodes to this binary tree.
157
- * In this scenario, null nodes serve as "sentinel nodes," "virtual nodes," or "placeholder nodes."
158
- */
159
- /**
160
- * The `add` function adds a new node to a binary tree, either by ID or by creating a new node with a given value.
161
- * @param {BinaryTreeNodeKey | N | null} keyOrNode - The `keyOrNode` parameter can be either a `BinaryTreeNodeKey`, which
162
- * is a number representing the ID of a binary tree node, or it can be a `N` object, which represents a binary tree
163
- * node itself. It can also be `null` if no node is specified.
164
- * @param [val] - The `val` parameter is an optional value that can be assigned to the `val` property of the new node
165
- * being added to the binary tree.
166
- * @returns The function `add` returns either the inserted node (`N`), `null`, or `undefined`.
184
+ * Add a node with the given key and value to the binary tree.
185
+ * @param {BinaryTreeNodeKey | N | null} keyOrNode - The key or node to add to the binary tree.
186
+ * @param {N['val']} val - The value for the new node (optional).
187
+ * @returns {N | null | undefined} - The inserted node, or null if nothing was inserted, or undefined if the operation failed.
167
188
  */
168
189
  add(keyOrNode, val) {
169
190
  const _bfs = (root, newNode) => {
@@ -226,12 +247,12 @@ class BinaryTree {
226
247
  * values, and adds them to the binary tree.
227
248
  * @param {(BinaryTreeNodeKey | null)[] | (N | null)[]} keysOrNodes - An array of BinaryTreeNodeKey or BinaryTreeNode
228
249
  * objects, or null values.
229
- * @param {N['val'][]} [data] - The `data` parameter is an optional array of values (`N['val'][]`) that corresponds to
230
- * the nodes or node IDs being added. It is used to set the value of each node being added. If `data` is not provided,
250
+ * @param {N['val'][]} [values] - The `values` parameter is an optional array of values (`N['val'][]`) that corresponds to
251
+ * the nodes or node IDs being added. It is used to set the value of each node being added. If `values` is not provided,
231
252
  * the value of the nodes will be `undefined`.
232
253
  * @returns The function `addMany` returns an array of `N`, `null`, or `undefined` values.
233
254
  */
234
- addMany(keysOrNodes, data) {
255
+ addMany(keysOrNodes, values) {
235
256
  // TODO not sure addMany not be run multi times
236
257
  const inserted = [];
237
258
  for (let i = 0; i < keysOrNodes.length; i++) {
@@ -244,7 +265,7 @@ class BinaryTree {
244
265
  inserted.push(this.add(null));
245
266
  continue;
246
267
  }
247
- const val = data === null || data === void 0 ? void 0 : data[i];
268
+ const val = values === null || values === void 0 ? void 0 : values[i];
248
269
  inserted.push(this.add(keyOrNode, val));
249
270
  }
250
271
  return inserted;
@@ -263,11 +284,12 @@ class BinaryTree {
263
284
  return keysOrNodes.length === this.addMany(keysOrNodes, data).length;
264
285
  }
265
286
  /**
266
- * The `delete` function in TypeScript is used to delete a node from a binary search tree and returns an array of objects
267
- * containing the deleted node and the node that needs to be balanced.
268
- * @param {N | BinaryTreeNodeKey} nodeOrKey - The `nodeOrKey` parameter can be either a node object (`N`) or a binary tree
269
- * node ID (`BinaryTreeNodeKey`).
270
- * @returns The function `delete` returns an array of `BinaryTreeDeletedResult<N>` objects.
287
+ * The `delete` function removes a node from a binary search tree and returns the deleted node along
288
+ * with the parent node that needs to be balanced.
289
+ * @param {N | BinaryTreeNodeKey} nodeOrKey - The `nodeOrKey` parameter can be either a node (`N`) or
290
+ * a key (`BinaryTreeNodeKey`). If it is a key, the function will find the corresponding node in the
291
+ * binary tree.
292
+ * @returns an array of `BinaryTreeDeletedResult<N>` objects.
271
293
  */
272
294
  delete(nodeOrKey) {
273
295
  const bstDeletedResult = [];
@@ -313,10 +335,16 @@ class BinaryTree {
313
335
  return bstDeletedResult;
314
336
  }
315
337
  /**
316
- * The function calculates the depth of a node in a binary tree.
317
- * @param {N | BinaryTreeNodeKey | null} distNode - The `distNode` parameter can be any node of the tree
318
- * @param {N | BinaryTreeNodeKey | null} beginRoot - The `beginRoot` parameter can be the predecessor node of distNode
319
- * @returns the depth of the given node or binary tree.
338
+ * The function `getDepth` calculates the depth of a given node in a binary tree relative to a
339
+ * specified root node.
340
+ * @param {N | BinaryTreeNodeKey | null} distNode - The `distNode` parameter represents the node
341
+ * whose depth we want to find in the binary tree. It can be either a node object (`N`), a key value
342
+ * of the node (`BinaryTreeNodeKey`), or `null`.
343
+ * @param {N | BinaryTreeNodeKey | null} beginRoot - The `beginRoot` parameter represents the
344
+ * starting node from which we want to calculate the depth. It can be either a node object or the key
345
+ * of a node in the binary tree. If no value is provided for `beginRoot`, it defaults to the root
346
+ * node of the binary tree.
347
+ * @returns the depth of the `distNode` relative to the `beginRoot`.
320
348
  */
321
349
  getDepth(distNode, beginRoot = this.root) {
322
350
  if (typeof distNode === 'number')
@@ -334,11 +362,15 @@ class BinaryTree {
334
362
  return depth;
335
363
  }
336
364
  /**
337
- * The `getHeight` function calculates the maximum height of a binary tree, either recursively or iteratively.
338
- * @param {N | BinaryTreeNodeKey | null} [beginRoot] - The `beginRoot` parameter is optional and can be of type `N` (a
339
- * generic type representing a node in a binary tree), `BinaryTreeNodeKey` (a type representing the ID of a binary tree
340
- * node), or `null`.
341
- * @param iterationType - The `iterationType` parameter is an optional parameter of type `IterationType`. It represents the type of
365
+ * The `getHeight` function calculates the maximum height of a binary tree using either recursive or
366
+ * iterative approach.
367
+ * @param {N | BinaryTreeNodeKey | null} beginRoot - The `beginRoot` parameter represents the
368
+ * starting node from which the height of the binary tree is calculated. It can be either a node
369
+ * object (`N`), a key value of a node in the tree (`BinaryTreeNodeKey`), or `null` if no starting
370
+ * node is specified. If `
371
+ * @param iterationType - The `iterationType` parameter is used to determine whether to calculate the
372
+ * height of the binary tree using a recursive approach or an iterative approach. It can have two
373
+ * possible values:
342
374
  * @returns the height of the binary tree.
343
375
  */
344
376
  getHeight(beginRoot = this.root, iterationType = this.iterationType) {
@@ -376,13 +408,14 @@ class BinaryTree {
376
408
  }
377
409
  }
378
410
  /**
379
- * The `getMinHeight` function calculates the minimum height of a binary tree using either a recursive or iterative
380
- * approach.
381
- * @param {N | null} [beginRoot] - The `beginRoot` parameter is an optional parameter of type `N` or `null`. It
382
- * represents the starting node from which to calculate the minimum height of a binary tree. If no value is provided
383
- * for `beginRoot`, the `this.root` property is used as the default value.
384
- * @param iterationType - The `iterationType` parameter is an optional parameter of type `IterationType`. It represents the type of loop
385
- * @returns The function `getMinHeight` returns the minimum height of the binary tree.
411
+ * The `getMinHeight` function calculates the minimum height of a binary tree using either a
412
+ * recursive or iterative approach.
413
+ * @param {N | null} beginRoot - The `beginRoot` parameter is the starting node from which we want to
414
+ * calculate the minimum height of the tree. It is optional and defaults to the root of the tree if
415
+ * not provided.
416
+ * @param iterationType - The `iterationType` parameter is used to determine the method of iteration
417
+ * to calculate the minimum height of a binary tree. It can have two possible values:
418
+ * @returns The function `getMinHeight` returns the minimum height of a binary tree.
386
419
  */
387
420
  getMinHeight(beginRoot = this.root, iterationType = this.iterationType) {
388
421
  var _a, _b, _c;
@@ -429,27 +462,35 @@ class BinaryTree {
429
462
  }
430
463
  }
431
464
  /**
432
- * The function checks if a binary tree is perfectly balanced by comparing the minimum height and the height of the
433
- * tree.
434
- * @param {N | null} [beginRoot] - The parameter `beginRoot` is of type `N` or `null`. It represents the root node of a
435
- * tree or null if the tree is empty.
465
+ * The function checks if a binary tree is perfectly balanced by comparing the minimum height and the
466
+ * height of the tree.
467
+ * @param {N | null} beginRoot - The parameter `beginRoot` is of type `N | null`, which means it can
468
+ * either be of type `N` (representing a node in a tree) or `null` (representing an empty tree).
436
469
  * @returns The method is returning a boolean value.
437
470
  */
438
471
  isPerfectlyBalanced(beginRoot = this.root) {
439
472
  return this.getMinHeight(beginRoot) + 1 >= this.getHeight(beginRoot);
440
473
  }
441
474
  /**
442
- * The function `getNodes` returns an array of nodes that match a given property name and value in a binary tree.
443
- * @param callback
444
- * @param {BinaryTreeNodeKey | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeKey` or a
445
- * generic type `N`. It represents the property of the binary tree node that you want to search for.
446
- * specifies the property name to use when searching for nodes. If not provided, it defaults to 'key'.
447
- * @param {boolean} [onlyOne] - The `onlyOne` parameter is an optional boolean parameter that determines whether to
448
- * return only one node that matches the given `nodeProperty` or `propertyName`. If `onlyOne` is set to `true`, the
449
- * function will stop traversing the tree and return the first matching node. If `only
450
- * @param beginRoot
451
- * @param iterationType - The `iterationType` parameter is an optional parameter of type `IterationType`. It represents the type of loop
452
- * @returns an array of nodes (type N).
475
+ * The function `getNodes` returns an array of nodes that match a given node property, using either
476
+ * recursive or iterative traversal.
477
+ * @param {BinaryTreeNodeKey | N} nodeProperty - The `nodeProperty` parameter is either a
478
+ * `BinaryTreeNodeKey` or a generic type `N`. It represents the property of the node that we are
479
+ * searching for. It can be a specific key value or any other property of the node.
480
+ * @param callback - The `callback` parameter is a function that takes a node as input and returns a
481
+ * value. This value is compared with the `nodeProperty` parameter to determine if the node should be
482
+ * included in the result. The `callback` parameter has a default value of
483
+ * `this._defaultCallbackByKey`, which
484
+ * @param [onlyOne=false] - A boolean value indicating whether to stop searching after finding the
485
+ * first node that matches the nodeProperty. If set to true, the function will return an array with
486
+ * only one element (or an empty array if no matching node is found). If set to false (default), the
487
+ * function will continue searching for all
488
+ * @param {N | null} beginRoot - The `beginRoot` parameter is the starting node from which the
489
+ * traversal of the binary tree will begin. It is optional and defaults to the root of the binary
490
+ * tree.
491
+ * @param iterationType - The `iterationType` parameter determines the type of iteration used to
492
+ * traverse the binary tree. It can have two possible values:
493
+ * @returns The function `getNodes` returns an array of nodes (`N[]`).
453
494
  */
454
495
  getNodes(nodeProperty, callback = this._defaultCallbackByKey, onlyOne = false, beginRoot = this.root, iterationType = this.iterationType) {
455
496
  if (!beginRoot)
@@ -487,13 +528,20 @@ class BinaryTree {
487
528
  return ans;
488
529
  }
489
530
  /**
490
- * The function checks if a binary tree node has a specific property.
491
- * @param callback - The `callback` parameter is a function that takes a node as a parameter and returns a value.
492
- * @param {BinaryTreeNodeKey | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeKey` or `N`.
493
- * It represents the property of the binary tree node that you want to check.
494
- * specifies the name of the property to be checked in the nodes. If not provided, it defaults to 'key'.
495
- * @param beginRoot - The `beginRoot` parameter is an optional parameter of type `N` or `null`. It represents the root node of a tree or null if the tree is empty.
496
- * @param iterationType - The `iterationType` parameter is an optional parameter of type `IterationType`. It represents the type of loop
531
+ * The function checks if a binary tree has a node with a given property or key.
532
+ * @param {BinaryTreeNodeKey | N} nodeProperty - The `nodeProperty` parameter is the key or value of
533
+ * the node that you want to find in the binary tree. It can be either a `BinaryTreeNodeKey` or a
534
+ * generic type `N`.
535
+ * @param callback - The `callback` parameter is a function that is used to determine whether a node
536
+ * matches the desired criteria. It takes a node as input and returns a boolean value indicating
537
+ * whether the node matches the criteria or not. The default callback function
538
+ * `this._defaultCallbackByKey` is used if no callback function is
539
+ * @param beginRoot - The `beginRoot` parameter is the starting point for the search. It specifies
540
+ * the node from which the search should begin. By default, it is set to `this.root`, which means the
541
+ * search will start from the root node of the binary tree. However, you can provide a different node
542
+ * as
543
+ * @param iterationType - The `iterationType` parameter specifies the type of iteration to be
544
+ * performed when searching for nodes in the binary tree. It can have one of the following values:
497
545
  * @returns a boolean value.
498
546
  */
499
547
  has(nodeProperty, callback = this._defaultCallbackByKey, beginRoot = this.root, iterationType = this.iterationType) {
@@ -501,17 +549,19 @@ class BinaryTree {
501
549
  return this.getNodes(nodeProperty, callback, true, beginRoot, iterationType).length > 0;
502
550
  }
503
551
  /**
504
- * The function returns the first node that matches the given property name and value, or null if no matching node is
505
- * found.
506
- * @param callback - The `callback` parameter is a function that takes a node as a parameter and returns a value.
507
- * @param {BinaryTreeNodeKey | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeKey` or `N`.
508
- * It represents the property of the binary tree node that you want to search for.
509
- * specifies the property name to be used for searching the binary tree nodes. If this parameter is not provided, the
510
- * default value is set to `'key'`.
511
- * @param beginRoot - The `beginRoot` parameter is an optional parameter of type `N` or `null`. It represents the root node of a tree or null if the tree is empty.
512
- * @param iterationType - The `iterationType` parameter is an optional parameter of type `IterationType`. It represents the type of loop used to traverse the binary tree.
513
- * @returns either the value of the specified property of the node, or the node itself if no property name is provided.
514
- * If no matching node is found, it returns null.
552
+ * The function `get` returns the first node in a binary tree that matches the given property or key.
553
+ * @param {BinaryTreeNodeKey | N} nodeProperty - The `nodeProperty` parameter is the key or value of
554
+ * the node that you want to find in the binary tree. It can be either a `BinaryTreeNodeKey` or `N`
555
+ * type.
556
+ * @param callback - The `callback` parameter is a function that is used to determine whether a node
557
+ * matches the desired criteria. It takes a node as input and returns a boolean value indicating
558
+ * whether the node matches the criteria or not. The default callback function
559
+ * (`this._defaultCallbackByKey`) is used if no callback function is
560
+ * @param beginRoot - The `beginRoot` parameter is the starting point for the search. It specifies
561
+ * the root node from which the search should begin.
562
+ * @param iterationType - The `iterationType` parameter specifies the type of iteration to be
563
+ * performed when searching for a node in the binary tree. It can have one of the following values:
564
+ * @returns either the found node (of type N) or null if no node is found.
515
565
  */
516
566
  get(nodeProperty, callback = this._defaultCallbackByKey, beginRoot = this.root, iterationType = this.iterationType) {
517
567
  var _a;
@@ -519,14 +569,14 @@ class BinaryTree {
519
569
  return (_a = this.getNodes(nodeProperty, callback, true, beginRoot, iterationType)[0]) !== null && _a !== void 0 ? _a : null;
520
570
  }
521
571
  /**
522
- * The function `getPathToRoot` returns an array of nodes representing the path from a given node to the root node, with
523
- * an option to reverse the order of the nodes.
524
- * type that represents a node in your specific implementation.
525
- * @param beginRoot - The `beginRoot` parameter is of type `N` and represents the starting node from which you want to
526
- * @param {boolean} [isReverse=true] - The `isReverse` parameter is a boolean flag that determines whether the resulting
527
- * path should be reversed or not. If `isReverse` is set to `true`, the path will be reversed before returning it. If
528
- * `isReverse` is set to `false` or not provided, the path will
529
- * @returns The function `getPathToRoot` returns an array of nodes (`N[]`).
572
+ * The function `getPathToRoot` returns an array of nodes starting from a given node and traversing
573
+ * up to the root node, with the option to reverse the order of the nodes.
574
+ * @param {N} beginRoot - The `beginRoot` parameter represents the starting node from which you want
575
+ * to find the path to the root node.
576
+ * @param [isReverse=true] - The `isReverse` parameter is a boolean flag that determines whether the
577
+ * resulting path should be reversed or not. If `isReverse` is set to `true`, the path will be
578
+ * reversed before returning it. If `isReverse` is set to `false` or not provided, the path will
579
+ * @returns The function `getPathToRoot` returns an array of type `N[]`.
530
580
  */
531
581
  getPathToRoot(beginRoot, isReverse = true) {
532
582
  // TODO to support get path through passing key
@@ -541,16 +591,15 @@ class BinaryTree {
541
591
  return isReverse ? result.reverse() : result;
542
592
  }
543
593
  /**
544
- * The function `getLeftMost` returns the leftmost node in a binary tree, starting from a specified node or the root if
545
- * no node is specified.
546
- * @param {N | BinaryTreeNodeKey | null} [beginRoot] - The `beginRoot` parameter is optional and can be of type `N` (a
547
- * generic type representing a node in a binary tree), `BinaryTreeNodeKey` (a type representing the ID of a binary tree
548
- * node), or `null`.
549
- * @param iterationType - The `iterationType` parameter is an optional parameter of type `IterationType`. It represents the type of loop used to traverse the binary tree.
550
- * @returns The function `getLeftMost` returns the leftmost node in a binary tree. If the `beginRoot` parameter is
551
- * provided, it starts the traversal from that node. If `beginRoot` is not provided or is `null`, it starts the traversal
552
- * from the root of the binary tree. The function returns the leftmost node found during the traversal. If no leftmost
553
- * node is found (
594
+ * The function `getLeftMost` returns the leftmost node in a binary tree, either using recursive or
595
+ * iterative traversal.
596
+ * @param {N | BinaryTreeNodeKey | null} beginRoot - The `beginRoot` parameter is the starting point
597
+ * for finding the leftmost node in a binary tree. It can be either a node object (`N`), a key value
598
+ * of a node (`BinaryTreeNodeKey`), or `null` if the tree is empty.
599
+ * @param iterationType - The `iterationType` parameter is used to determine the type of iteration to
600
+ * be performed when finding the leftmost node in a binary tree. It can have two possible values:
601
+ * @returns The function `getLeftMost` returns the leftmost node (`N`) in a binary tree. If there is
602
+ * no leftmost node, it returns `null`.
554
603
  */
555
604
  getLeftMost(beginRoot = this.root, iterationType = this.iterationType) {
556
605
  if (typeof beginRoot === 'number')
@@ -576,15 +625,15 @@ class BinaryTree {
576
625
  }
577
626
  }
578
627
  /**
579
- * The `getRightMost` function returns the rightmost node in a binary tree, either recursively or iteratively using tail
580
- * recursion optimization.
581
- * @param {N | null} [beginRoot] - The `node` parameter is an optional parameter of type `N` or `null`. It represents the
582
- * starting node from which we want to find the rightmost node. If no node is provided, the function will default to
583
- * using the root node of the data structure.
584
- * @param iterationType - The `iterationType` parameter is an optional parameter of type `IterationType`. It represents the type of loop
585
- * @returns The `getRightMost` function returns the rightmost node in a binary tree. If the `node` parameter is provided,
586
- * it returns the rightmost node starting from that node. If the `node` parameter is not provided, it returns the
587
- * rightmost node starting from the root of the binary tree.
628
+ * The function `getRightMost` returns the rightmost node in a binary tree, either recursively or
629
+ * iteratively.
630
+ * @param {N | null} beginRoot - The `beginRoot` parameter is the starting node from which we want to
631
+ * find the rightmost node. It is of type `N | null`, which means it can either be a node of type `N`
632
+ * or `null`. If it is `null`, it means there is no starting node
633
+ * @param iterationType - The `iterationType` parameter is used to determine the type of iteration to
634
+ * be performed when finding the rightmost node in a binary tree. It can have two possible values:
635
+ * @returns The function `getRightMost` returns the rightmost node (`N`) in a binary tree. If the
636
+ * `beginRoot` parameter is `null`, it returns `null`.
588
637
  */
589
638
  getRightMost(beginRoot = this.root, iterationType = this.iterationType) {
590
639
  // TODO support get right most by passing key in
@@ -609,10 +658,13 @@ class BinaryTree {
609
658
  }
610
659
  }
611
660
  /**
612
- * The function checks if a binary search tree is valid by traversing it either recursively or iteratively.
613
- * @param {N | null} beginRoot - The `node` parameter represents the root node of a binary search tree (BST).
614
- * @param iterationType - The `iterationType` parameter is an optional parameter of type `IterationType`. It represents the type of loop
615
- * @returns a boolean value.
661
+ * The function `isSubtreeBST` checks if a given binary tree is a valid binary search tree.
662
+ * @param {N} beginRoot - The `beginRoot` parameter is the root node of the binary tree that you want
663
+ * to check if it is a binary search tree (BST) subtree.
664
+ * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
665
+ * type of iteration to use when checking if a subtree is a binary search tree (BST). It can have two
666
+ * possible values:
667
+ * @returns The function `isSubtreeBST` returns a boolean value.
616
668
  */
617
669
  isSubtreeBST(beginRoot, iterationType = this.iterationType) {
618
670
  // TODO there is a bug
@@ -646,8 +698,12 @@ class BinaryTree {
646
698
  }
647
699
  }
648
700
  /**
649
- * The function isBST checks if the binary tree is valid binary search tree.
650
- * @returns The `isBST()` function is returning a boolean value.
701
+ * The function checks if a binary tree is a binary search tree.
702
+ * @param iterationType - The parameter "iterationType" is used to specify the type of iteration to
703
+ * be used when checking if the binary tree is a binary search tree (BST). It is an optional
704
+ * parameter with a default value of "this.iterationType". The value of "this.iterationType" is not
705
+ * provided in
706
+ * @returns a boolean value.
651
707
  */
652
708
  isBST(iterationType = this.iterationType) {
653
709
  if (this.root === null)
@@ -655,13 +711,18 @@ class BinaryTree {
655
711
  return this.isSubtreeBST(this.root, iterationType);
656
712
  }
657
713
  /**
658
- * The function `subTreeTraverse` adds a delta value to a specified property of each node in a subtree.
659
- * @param {N | BinaryTreeNodeKey | null} beginRoot - The `beginRoot` parameter represents the root node of a binary
660
- * tree or the ID of a node in the binary tree. It can also be `null` if there is no subtree to add to.
661
- * @param callback - The `callback` parameter is a function that takes a node as a parameter and returns a value.
662
- * specifies the property of the binary tree node that should be modified. If not provided, it defaults to 'key'.
663
- * @param iterationType - The `iterationType` parameter is an optional parameter of type `IterationType`. It represents the type of loop
664
- * @returns a boolean value.
714
+ * The function `subTreeTraverse` traverses a binary tree and applies a callback function to each
715
+ * node, either recursively or iteratively.
716
+ * @param callback - The `callback` parameter is a function that will be called on each node in the
717
+ * subtree traversal. It takes a single argument, which is the current node being traversed, and
718
+ * returns a value. The return values from each callback invocation will be collected and returned as
719
+ * an array.
720
+ * @param {N | BinaryTreeNodeKey | null} beginRoot - The `beginRoot` parameter is the starting point
721
+ * for traversing the subtree. It can be either a node object, a key value of a node, or `null` to
722
+ * start from the root of the tree.
723
+ * @param iterationType - The `iterationType` parameter determines the type of traversal to be
724
+ * performed on the binary tree. It can have two possible values:
725
+ * @returns The function `subTreeTraverse` returns an array of `MapCallbackReturn<N>`.
665
726
  */
666
727
  subTreeTraverse(callback = this._defaultCallbackByKey, beginRoot = this.root, iterationType = this.iterationType) {
667
728
  if (typeof beginRoot === 'number')
@@ -689,13 +750,19 @@ class BinaryTree {
689
750
  return ans;
690
751
  }
691
752
  /**
692
- * The dfs function performs a depth-first search traversal on a binary tree and returns the accumulated properties of
693
- * each node based on the specified pattern and property name.
694
- * @param callback
695
- * @param beginRoot - The `beginRoot` parameter is an optional parameter of type `N` or `null`. It represents the
696
- * @param {'in' | 'pre' | 'post'} [pattern] - The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).
697
- * @param iterationType - The type of loop to use for the depth-first search traversal. The default value is `IterationType.ITERATIVE`.
698
- * @returns an instance of the BinaryTreeNodeProperties class, which contains the accumulated properties of the binary tree nodes based on the specified pattern and node or property name.
753
+ * The `dfs` function performs a depth-first search traversal on a binary tree, executing a callback
754
+ * function on each node according to a specified order pattern.
755
+ * @param callback - The `callback` parameter is a function that will be called on each node during
756
+ * the depth-first search traversal. It takes a node as input and returns a value. The default value
757
+ * is `this._defaultCallbackByKey`, which is a callback function defined elsewhere in the code.
758
+ * @param {DFSOrderPattern} [pattern=in] - The `pattern` parameter determines the order in which the
759
+ * nodes are visited during the depth-first search. There are three possible values for `pattern`:
760
+ * @param {N | null} beginRoot - The `beginRoot` parameter is the starting node for the depth-first
761
+ * search. It determines where the search will begin in the tree or graph structure. If `beginRoot`
762
+ * is `null`, an empty array will be returned.
763
+ * @param {IterationType} iterationType - The `iterationType` parameter determines the type of
764
+ * iteration used in the depth-first search algorithm. It can have two possible values:
765
+ * @returns The function `dfs` returns an array of `MapCallbackReturn<N>` values.
699
766
  */
700
767
  dfs(callback = this._defaultCallbackByKey, pattern = 'in', beginRoot = this.root, iterationType = types_1.IterationType.ITERATIVE) {
701
768
  if (!beginRoot)
@@ -769,11 +836,21 @@ class BinaryTree {
769
836
  }
770
837
  // --- start additional methods ---
771
838
  /**
772
- * The `listLevels` function collects nodes from a binary tree by a specified property and organizes them into levels.
773
- * @param callback - The `callback` parameter is a function that takes a node and a level as parameters and returns a value.
774
- * @param withLevel - The `withLevel` parameter is a boolean flag that determines whether to include the level of each node in the result. If `withLevel` is set to `true`, the function will include the level of each node in the result. If `withLevel` is set to `false` or not provided, the function will not include the level of each node in the result.
775
- * @param beginRoot - The `beginRoot` parameter is an optional parameter of type `N` or `null`. It represents the root node of a tree or null if the tree is empty.
776
- * @param iterationType
839
+ * The bfs function performs a breadth-first search traversal on a binary tree, executing a callback
840
+ * function on each node.
841
+ * @param callback - The `callback` parameter is a function that will be called for each node in the
842
+ * breadth-first search. It takes a node of type `N` as its argument and returns a value of type
843
+ * `BFSCallbackReturn<N>`. The default value for this parameter is `this._defaultCallbackByKey
844
+ * @param {boolean} [withLevel=false] - The `withLevel` parameter is a boolean flag that determines
845
+ * whether or not to include the level of each node in the callback function. If `withLevel` is set
846
+ * to `true`, the level of each node will be passed as an argument to the callback function. If
847
+ * `withLevel` is
848
+ * @param {N | null} beginRoot - The `beginRoot` parameter is the starting node for the breadth-first
849
+ * search. It determines from which node the search will begin. If `beginRoot` is `null`, the search
850
+ * will not be performed and an empty array will be returned.
851
+ * @param iterationType - The `iterationType` parameter determines the type of iteration to be used
852
+ * in the breadth-first search (BFS) algorithm. It can have two possible values:
853
+ * @returns The function `bfs` returns an array of `BFSCallbackReturn<N>[]`.
777
854
  */
778
855
  bfs(callback = this._defaultCallbackByKey, withLevel = false, beginRoot = this.root, iterationType = this.iterationType) {
779
856
  if (!beginRoot)
@@ -804,9 +881,9 @@ class BinaryTree {
804
881
  return ans;
805
882
  }
806
883
  /**
807
- * The function returns the predecessor of a given node in a binary tree.
808
- * @param node - The parameter `node` is a BinaryTreeNode object, representing a node in a binary tree.
809
- * @returns the predecessor of the given node in a binary tree.
884
+ * The function returns the predecessor node of a given node in a binary tree.
885
+ * @param {N} node - The parameter "node" represents a node in a binary tree.
886
+ * @returns The function `getPredecessor` returns the predecessor node of the given node `node`.
810
887
  */
811
888
  getPredecessor(node) {
812
889
  if (node.left) {
@@ -825,16 +902,23 @@ class BinaryTree {
825
902
  /**
826
903
  * Time complexity is O(n)
827
904
  * Space complexity of Iterative dfs equals to recursive dfs which is O(n) because of the stack
828
- */
829
- /**
830
- * The `morris` function performs an in-order, pre-order, or post-order traversal on a binary tree using the Morris traversal algorithm.
831
905
  * The Morris algorithm only modifies the tree's structure during traversal; once the traversal is complete,
832
906
  * the tree's structure should be restored to its original state to maintain the tree's integrity.
833
907
  * This is because the purpose of the Morris algorithm is to save space rather than permanently alter the tree's shape.
834
- * @param {'in' | 'pre' | 'post'} [pattern] - The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).
835
- * @param callback - The `callback` parameter is a function that takes a node as a parameter and returns a value.
836
- * @param beginRoot - The `beginRoot` parameter is an optional parameter of type `N` or `null`. It represents the
837
- * @returns An array of BinaryTreeNodeProperties<N> objects.
908
+ */
909
+ /**
910
+ * The `morris` function performs a depth-first traversal of a binary tree using the Morris traversal
911
+ * algorithm and returns an array of values obtained by applying a callback function to each node.
912
+ * @param callback - The `callback` parameter is a function that will be called on each node in the
913
+ * tree. It takes a node of type `N` as input and returns a value of type `MapCallbackReturn<N>`. The
914
+ * default value for this parameter is `this._defaultCallbackByKey`.
915
+ * @param {DFSOrderPattern} [pattern=in] - The `pattern` parameter in the `morris` function
916
+ * determines the order in which the nodes of a binary tree are traversed. It can have one of the
917
+ * following values:
918
+ * @param {N | null} beginRoot - The `beginRoot` parameter is the starting node for the Morris
919
+ * traversal. It specifies the root node of the tree from which the traversal should begin. If
920
+ * `beginRoot` is `null`, an empty array will be returned.
921
+ * @returns The `morris` function returns an array of `MapCallbackReturn<N>` values.
838
922
  */
839
923
  morris(callback = this._defaultCallbackByKey, pattern = 'in', beginRoot = this.root) {
840
924
  if (beginRoot === null)
@@ -921,14 +1005,15 @@ class BinaryTree {
921
1005
  return ans;
922
1006
  }
923
1007
  /**
924
- * The function adds a new node to a binary tree if there is an available position.
925
- * @param {N | null} newNode - The `newNode` parameter is of type `N | null`, which means it can either be a node of
926
- * type `N` or `null`. It represents the node that you want to add to the binary tree.
927
- * @param {N} parent - The parent parameter is of type N, which represents a node in a binary tree.
928
- * @returns either the left or right child node of the parent node, depending on which child is available for adding
929
- * the new node. If a new node is added, the function also updates the size of the binary tree. If neither the left nor
930
- * right child is available, the function returns undefined. If the parent node is null, the function also returns
931
- * undefined.
1008
+ * The function `_addTo` adds a new node to a binary tree if there is an available position.
1009
+ * @param {N | null} newNode - The `newNode` parameter represents the node that you want to add to
1010
+ * the binary tree. It can be either a node object or `null`.
1011
+ * @param {N} parent - The `parent` parameter represents the parent node to which the new node will
1012
+ * be added as a child.
1013
+ * @returns either the left or right child node of the parent node, depending on which child is
1014
+ * available for adding the new node. If a new node is added, the function also updates the size of
1015
+ * the binary tree. If neither the left nor right child is available, the function returns undefined.
1016
+ * If the parent node is null, the function also returns undefined.
932
1017
  */
933
1018
  _addTo(newNode, parent) {
934
1019
  if (parent) {
@@ -957,9 +1042,10 @@ class BinaryTree {
957
1042
  }
958
1043
  }
959
1044
  /**
960
- * The function sets the root property of an object to a given value, and if the value is not null, it also sets the
961
- * parent property of the value to undefined.
962
- * @param {N | null} v - The parameter `v` is of type `N | null`, which means it can either be of type `N` or `null`.
1045
+ * The function sets the root property of an object to a given value, and if the value is not null,
1046
+ * it also sets the parent property of the value to undefined.
1047
+ * @param {N | null} v - The parameter `v` is of type `N | null`, which means it can either be of
1048
+ * type `N` or `null`.
963
1049
  */
964
1050
  _setRoot(v) {
965
1051
  if (v) {
@@ -968,8 +1054,9 @@ class BinaryTree {
968
1054
  this._root = v;
969
1055
  }
970
1056
  /**
971
- * The function sets the size of a protected variable.
972
- * @param {number} v - number
1057
+ * The function sets the value of the protected property "_size" to the given number.
1058
+ * @param {number} v - The parameter "v" is a number that represents the size value that we want to
1059
+ * set.
973
1060
  */
974
1061
  _setSize(v) {
975
1062
  this._size = v;