@raikuxq/alg-ds 1.1.1 → 1.1.2

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 (47) hide show
  1. package/.idea/algorythmes.iml +15 -0
  2. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  3. package/.idea/deployment.xml +14 -0
  4. package/.idea/inspectionProfiles/Project_Default.xml +7 -0
  5. package/.idea/jsLinters/eslint.xml +6 -0
  6. package/.idea/misc.xml +6 -0
  7. package/.idea/modules.xml +8 -0
  8. package/.idea/vcs.xml +6 -0
  9. package/lib/algotirhms.ts +35 -0
  10. package/lib/constants.ts +3 -0
  11. package/lib/data-structures.ts +23 -0
  12. package/lib/helpers.ts +13 -0
  13. package/lib/sorts.ts +7 -0
  14. package/lib/types.ts +53 -0
  15. package/{src/exports → lib}/utils.ts +2 -2
  16. package/package.json +5 -3
  17. package/src/demo/demo.hashtable.ts +28 -28
  18. package/src/demo/performance/bst-compare.ts +1 -4
  19. package/src/index.ts +44 -42
  20. package/.eslintrc.js +0 -14
  21. package/jest.config.js +0 -4
  22. package/nodemon.json +0 -6
  23. package/src/exports/algotirhms.ts +0 -35
  24. package/src/exports/constants.ts +0 -3
  25. package/src/exports/helpers.ts +0 -13
  26. package/src/exports/main.ts +0 -21
  27. package/src/exports/sorts.ts +0 -7
  28. package/src/exports/types.ts +0 -53
  29. package/test/unit/algorithms/binary-search.test.ts +0 -25
  30. package/test/unit/algorithms/factorial.test.ts +0 -43
  31. package/test/unit/algorithms/fibonacci.test.ts +0 -41
  32. package/test/unit/algorithms/sorts.test.ts +0 -74
  33. package/test/unit/algorithms/transpose-matrix.test.ts +0 -39
  34. package/test/unit/data-structures/binary-tree/binary-search-tree.test.ts +0 -230
  35. package/test/unit/data-structures/graph/graph.create-from-matrix.test.ts +0 -106
  36. package/test/unit/data-structures/graph/graph.has-path.test.ts +0 -115
  37. package/test/unit/data-structures/graph/graph.presenter.lists.test.ts +0 -76
  38. package/test/unit/data-structures/graph/graph.presenter.matrix.test.ts +0 -73
  39. package/test/unit/data-structures/graph/graph.shortest-path.test.ts +0 -207
  40. package/test/unit/data-structures/graph/graph.test.ts +0 -394
  41. package/test/unit/data-structures/graph/graph.transpose.test.ts +0 -52
  42. package/test/unit/data-structures/hash-table/hash-table.test.ts +0 -176
  43. package/test/unit/data-structures/linked-list/linked-list.test.ts +0 -477
  44. package/test/unit/data-structures/looped-array/looped-array.test.ts +0 -387
  45. package/test/unit/data-structures/queue/queue.test.ts +0 -147
  46. package/test/unit/data-structures/stack/stack.test.ts +0 -155
  47. package/tsconfig.json +0 -26
@@ -0,0 +1,15 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="WEB_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$">
5
+ <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
6
+ <excludeFolder url="file://$MODULE_DIR$/.tmp" />
7
+ <excludeFolder url="file://$MODULE_DIR$/temp" />
8
+ <excludeFolder url="file://$MODULE_DIR$/tmp" />
9
+ <excludeFolder url="file://$MODULE_DIR$/build/coverage" />
10
+ <excludeFolder url="file://$MODULE_DIR$/coverage" />
11
+ </content>
12
+ <orderEntry type="inheritedJdk" />
13
+ <orderEntry type="sourceFolder" forTests="false" />
14
+ </component>
15
+ </module>
@@ -0,0 +1,5 @@
1
+ <component name="ProjectCodeStyleConfiguration">
2
+ <state>
3
+ <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
4
+ </state>
5
+ </component>
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="PublishConfigData">
4
+ <serverData>
5
+ <paths name="raikuhost">
6
+ <serverdata>
7
+ <mappings>
8
+ <mapping local="$PROJECT_DIR$" web="/" />
9
+ </mappings>
10
+ </serverdata>
11
+ </paths>
12
+ </serverData>
13
+ </component>
14
+ </project>
@@ -0,0 +1,7 @@
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="DuplicatedCode" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
5
+ <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
6
+ </profile>
7
+ </component>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="EslintConfiguration">
4
+ <option name="fix-on-save" value="true" />
5
+ </component>
6
+ </project>
package/.idea/misc.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="JavaScriptSettings">
4
+ <option name="languageLevel" value="ES6" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/algorythmes.iml" filepath="$PROJECT_DIR$/.idea/algorythmes.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,35 @@
1
+ import { factorial, memoizedFactorial } from "../src/algorithms/factorial";
2
+ import { fibonacci, memoizedFibonacci } from "../src/algorithms/fibonacci";
3
+ import { binarySearch } from "../src/algorithms/binary-search";
4
+ import { transposeMatrix } from "../src/algorithms/transpose-matrix";
5
+ import { transposeDirectedGraph } from "../src/data-structures/Graph/transposing/transposeDirectedGraph";
6
+ import BFSIterationStrategy from "../src/data-structures/Graph/strategy/BFSIterationStrategy";
7
+ import DFSIterationStrategy from "../src/data-structures/Graph/strategy/DFSIterationStrategy";
8
+ import DijkstraIterationStrategy from "../src/data-structures/Graph/strategy/DijkstraIterationStrategy";
9
+ import GraphIteratorBFS from "../src/data-structures/Graph/iterator/GraphIteratorBFS";
10
+ import GraphIteratorDFS from "../src/data-structures/Graph/iterator/GraphIteratorDFS";
11
+ import GraphIteratorDijkstra from "../src/data-structures/Graph/iterator/GraphIteratorDijkstra";
12
+ import { hasPath } from "../src/data-structures/Graph/searching/hasPath";
13
+ import { shortestPath } from "../src/data-structures/Graph/searching/shortestPath";
14
+ import { presenterAdjacencyMatrix } from "../src/data-structures/Graph/presenter/presenterAdjacencyMatrix";
15
+ import { presenterAdjacencyLists } from "../src/data-structures/Graph/presenter/presenterAdjacencyLists";
16
+
17
+ export {
18
+ binarySearch,
19
+ factorial,
20
+ memoizedFactorial,
21
+ memoizedFibonacci,
22
+ fibonacci,
23
+ transposeMatrix,
24
+ GraphIteratorDFS,
25
+ presenterAdjacencyLists,
26
+ presenterAdjacencyMatrix,
27
+ hasPath,
28
+ shortestPath,
29
+ DijkstraIterationStrategy,
30
+ DFSIterationStrategy,
31
+ BFSIterationStrategy,
32
+ GraphIteratorBFS,
33
+ GraphIteratorDijkstra,
34
+ transposeDirectedGraph,
35
+ };
@@ -0,0 +1,3 @@
1
+ import { EDGE_EXISTS_STATE, EDGE_NOT_EXISTS_STATE } from "../src/constants";
2
+
3
+ export { EDGE_NOT_EXISTS_STATE, EDGE_EXISTS_STATE };
@@ -0,0 +1,23 @@
1
+ import Queue from "../src/data-structures/Queue/Queue";
2
+ import Stack from "../src/data-structures/Stack/Stack";
3
+ import UndirectedGraph from "../src/data-structures/Graph/UndirectedGraph";
4
+ import DirectedGraph from "../src/data-structures/Graph/DirectedGraph";
5
+ import BinarySearchTree from "../src/data-structures/BinaryTree/BinarySearchTree/BinarySearchTree";
6
+ import RandBinarySearchTree from "../src/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchTree";
7
+ import DoubleLinkedList from "../src/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedList";
8
+ import SingleLinkedList from "../src/data-structures/LinkedList/SingleLinkedList/SingleLinkedList";
9
+ import LoopedArray from "../src/data-structures/LoopedArray/LoopedArray";
10
+ import HashTable from "../src/data-structures/HashTable/HashTable";
11
+
12
+ export {
13
+ Stack,
14
+ Queue,
15
+ SingleLinkedList,
16
+ DoubleLinkedList,
17
+ RandBinarySearchTree,
18
+ BinarySearchTree,
19
+ DirectedGraph,
20
+ UndirectedGraph,
21
+ LoopedArray,
22
+ HashTable,
23
+ };
package/lib/helpers.ts ADDED
@@ -0,0 +1,13 @@
1
+ import { generateRandomGraph } from "../src/data-structures/Graph/demo/generateRandomGraph";
2
+ import { createLinkedList } from "../src/helpers/createLinkedList";
3
+ import { createBinaryTree } from "../src/helpers/createBinaryTree";
4
+ import { createGraph } from "../src/helpers/createGraph";
5
+ import { createGraphFromMatrix } from "../src/helpers/createGraphFromMatrix";
6
+
7
+ export {
8
+ createGraph,
9
+ createGraphFromMatrix,
10
+ createBinaryTree,
11
+ createLinkedList,
12
+ generateRandomGraph,
13
+ };
package/lib/sorts.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { bubbleSort } from "../src/algorithms/sorts/bubble-sort";
2
+ import { selectSort } from "../src/algorithms/sorts/select-sort";
3
+ import { mergeSort } from "../src/algorithms/sorts/merge-sort";
4
+ import { insertionSort } from "../src/algorithms/sorts/insertion-sort";
5
+ import { quickSort } from "../src/algorithms/sorts/quick-sort";
6
+
7
+ export { bubbleSort, insertionSort, mergeSort, selectSort, quickSort };
package/lib/types.ts ADDED
@@ -0,0 +1,53 @@
1
+ import { ArrayMatrix } from "../src/types/ArrayMatrix";
2
+ import { EnumTreeTraversalType } from "../src/types/EnumTreeTraversalType";
3
+ import { EnumBinarySearchTreeType } from "../src/types/EnumBinarySearchTreeType";
4
+ import { EnumGraphTraversalType } from "../src/types/EnumGraphTraversalType";
5
+ import { EnumGraphType } from "../src/types/EnumGraphType";
6
+ import { EnumLinkedListType } from "../src/types/EnumLinkedListType";
7
+ import { EnumRandomGenerationFormat } from "../src/types/EnumRandomGenerationFormat";
8
+ import { EnumSortType } from "../src/types/EnumSortType";
9
+ import { FnSort } from "../src/types/FnSort";
10
+ import { FnCompareTwo } from "../src/types/FnCompareTwo";
11
+ import { FnToMemoize } from "../src/types/FnToMemoize";
12
+ import IArrayFacade from "../src/types/IArrayFacade";
13
+ import IBiDirectIterator from "../src/types/IBiDirectIterator";
14
+ import IBiDirectIterable from "../src/types/IBiDirectIterable";
15
+ import IIterable from "../src/types/IIterable";
16
+ import IIterator from "../src/types/IIterator";
17
+ import IBinaryTree from "../src/types/IBinaryTree";
18
+ import IConvertableToArray from "../src/types/IConvertableToArray";
19
+ import IGraph from "../src/types/IGraph";
20
+ import IGraphCreator from "../src/types/IGraphCreator";
21
+ import IGraphIterationStrategy from "../src/types/IGraphIterationStrategy";
22
+ import IGraphIterator from "../src/types/IGraphIterator";
23
+ import ILinearStorage from "../src/types/ILinearStorage";
24
+ import ILinearStorageRA from "../src/types/ILinearStorageRA";
25
+ import ILinkedList from "../src/types/ILinkedList";
26
+
27
+ export {
28
+ IGraph,
29
+ IGraphIterator,
30
+ IGraphIterationStrategy,
31
+ IIterator,
32
+ IIterable,
33
+ IGraphCreator,
34
+ IBiDirectIterable,
35
+ IBiDirectIterator,
36
+ EnumGraphType,
37
+ EnumSortType,
38
+ FnSort,
39
+ EnumGraphTraversalType,
40
+ EnumTreeTraversalType,
41
+ EnumBinarySearchTreeType,
42
+ IBinaryTree,
43
+ EnumLinkedListType,
44
+ ILinkedList,
45
+ ILinearStorage,
46
+ ILinearStorageRA,
47
+ IArrayFacade,
48
+ IConvertableToArray,
49
+ ArrayMatrix,
50
+ FnCompareTwo,
51
+ EnumRandomGenerationFormat,
52
+ FnToMemoize,
53
+ };
@@ -1,4 +1,4 @@
1
- import { memoize } from "../algorithms/memoize";
1
+ import { memoize } from "../src/algorithms/memoize";
2
2
  import {
3
3
  getMinIndex,
4
4
  getMinIndexFromIndex,
@@ -7,7 +7,7 @@ import {
7
7
  roundNumber,
8
8
  swapArrayItems,
9
9
  perfAsync,
10
- } from "../utils";
10
+ } from "../src/utils";
11
11
 
12
12
  export {
13
13
  perf,
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "test": "jest",
5
5
  "dev": "nodemon",
6
6
  "build": "rimraf ./build && tsc",
7
- "start": "npm run build && node build/main.js",
7
+ "start": "npm run build && node --experimental-specifier-resolution=node .build/index.js",
8
8
  "lint": "yarn eslint . --ext .ts",
9
9
  "lint:fix": "yarn eslint --fix . --ext .ts"
10
10
  },
@@ -26,9 +26,11 @@
26
26
  "prettier": "^2.1.2",
27
27
  "rimraf": "^3.0.2",
28
28
  "ts-jest": "^26.4.1",
29
- "ts-node": "^8.10.2",
29
+ "ts-node": "^10.7.0",
30
+ "ts-node-esm": "^0.0.6",
30
31
  "typescript": "^4.0.3"
31
32
  },
32
33
  "dependencies": {},
33
- "version": "1.1.1"
34
+ "version": "1.1.2",
35
+ "type": "module"
34
36
  }
@@ -1,28 +1,28 @@
1
- import HashTable from "../data-structures/HashTable/HashTable";
2
-
3
- export const demoHashtable = (): void => {
4
- const hashTable = new HashTable<number>(15);
5
-
6
- // emulate 66% load
7
- for (let i = 0; i < 10; i++) {
8
- hashTable.set(`key${i * 2}`, i * 2);
9
- }
10
- console.log(hashTable);
11
-
12
- for (let i = 10; i < 15; i++) {
13
- hashTable.set(`key${i * 2}`, i * 2);
14
- }
15
- console.log(hashTable);
16
- console.log("\n length:", hashTable.length());
17
-
18
- hashTable.set("key4", 10000);
19
- console.log("\n", hashTable.get("key4"));
20
- hashTable.delete("key4");
21
- console.log("\n has key4:", hashTable.has("key4"));
22
- hashTable.set("key4", 20000);
23
- console.log("\n has key4:", hashTable.has("key4"));
24
- console.log("\n key4 value:", hashTable.get("key4"));
25
- console.log("\n", hashTable);
26
- hashTable.clear();
27
- console.log("\n", hashTable);
28
- };
1
+ import HashTable from "../data-structures/HashTable/HashTable";
2
+
3
+ export const demoHashtable = (): void => {
4
+ const hashTable = new HashTable<number>(15);
5
+
6
+ // emulate 66% load
7
+ for (let i = 0; i < 10; i++) {
8
+ hashTable.set(`key${i * 2}`, i * 2);
9
+ }
10
+ console.log(hashTable);
11
+
12
+ for (let i = 10; i < 15; i++) {
13
+ hashTable.set(`key${i * 2}`, i * 2);
14
+ }
15
+ console.log(hashTable);
16
+ console.log("\n length:", hashTable.length());
17
+
18
+ hashTable.set("key4", 10000);
19
+ console.log("\n", hashTable.get("key4"));
20
+ hashTable.delete("key4");
21
+ console.log("\n has key4:", hashTable.has("key4"));
22
+ hashTable.set("key4", 20000);
23
+ console.log("\n has key4:", hashTable.has("key4"));
24
+ console.log("\n key4 value:", hashTable.get("key4"));
25
+ console.log("\n", hashTable);
26
+ hashTable.clear();
27
+ console.log("\n", hashTable);
28
+ };
@@ -1,9 +1,6 @@
1
1
  import RandBinarySearchTree from "../../data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchTree";
2
2
  import BinarySearchTree from "../../data-structures/BinaryTree/BinarySearchTree/BinarySearchTree";
3
- import { EnumTreeTraversalType } from "../../types/EnumTreeTraversalType";
4
3
  import IBinaryTree from "../../types/IBinaryTree";
5
- // eslint-disable-next-line @typescript-eslint/no-var-requires
6
- const util = require("util");
7
4
 
8
5
  const logTree = <T>(tree: IBinaryTree<T>) => {
9
6
  console.log("HEIGHT");
@@ -22,7 +19,7 @@ export const bstCompare = (): void => {
22
19
 
23
20
  const arraySrc = Array.from(Array(1000).keys());
24
21
 
25
- arraySrc.forEach((num, index) => {
22
+ arraySrc.forEach((num) => {
26
23
  bstLeaf.insert(num);
27
24
  bstRand.insert(num);
28
25
  });
package/src/index.ts CHANGED
@@ -1,42 +1,44 @@
1
- /**
2
- * Write your code here
3
- */
4
- // import { demoHashtable } from "./demo/demo.hashtable";
5
- // import { demoBst, demoBstObjects } from "./demo/demo.bst";
6
- // import { bstCompare } from "./demo/performance/bst-compare";
7
- // import { demoStack } from "./demo/demo.stack";
8
- // import { perfQueue, perfStack } from "./demo/performance/ds-compare";
9
- // import { demoLinkedList } from "./demo/demo.linked-list";
10
- // import { demoQueue } from "./demo/demo.queue";
11
- // import {
12
- // demoDirectedGraph,
13
- // demoGraphGenerated,
14
- // demoUndirectedGraph,
15
- // } from "./demo/demo.graph";
16
- // import { demoLoopedArray } from "./demo/demo.looped-array";
17
- // import { compareAllSortTypes } from "./demo/performance/sort-compare";
18
- //
19
- // demoLinkedList();
20
- // // console.log("================================================================");
21
- // demoLoopedArray();
22
- // // console.log("================================================================");
23
- // demoQueue();
24
- // // console.log("================================================================");
25
- // demoStack();
26
- // // console.log("================================================================");
27
- // demoUndirectedGraph();
28
- // // console.log("================================================================");
29
- // demoDirectedGraph();
30
- // // console.log("================================================================");
31
- // demoGraphGenerated();
32
- // // console.log("================================================================");
33
- // compareAllSortTypes();
34
- // // console.log("===========================================================");
35
- // perfQueue();
36
- // // console.log("===========================================================");
37
- // perfStack();
38
- // // console.log("===========================================================");
39
- // demoBst();
40
- // // console.log("===========================================================");
41
- // bstCompare();
42
- // demoHashtable();
1
+ /**
2
+ * Write your code here
3
+ */
4
+
5
+ // import { demoHashtable } from "./demo/demo.hashtable";
6
+ // import { demoBst, demoBstObjects } from "./demo/demo.bst";
7
+ // import { bstCompare } from "./demo/performance/bst-compare";
8
+ // import { demoStack } from "./demo/demo.stack";
9
+ // import { perfQueue, perfStack } from "./demo/performance/ds-compare";
10
+ // import { demoLinkedList } from "./demo/demo.linked-list";
11
+ // import { demoQueue } from "./demo/demo.queue";
12
+ // import {
13
+ // demoDirectedGraph,
14
+ // demoGraphGenerated,
15
+ // demoUndirectedGraph,
16
+ // } from "./demo/demo.graph";
17
+ // import { demoLoopedArray } from "./demo/demo.looped-array";
18
+ // import { compareAllSortTypes } from "./demo/performance/sort-compare";
19
+ //
20
+ // demoLinkedList();
21
+ // // console.log("================================================================");
22
+ // demoLoopedArray();
23
+ // // console.log("================================================================");
24
+ // demoQueue();
25
+ // // console.log("================================================================");
26
+ // demoStack();
27
+ // // console.log("================================================================");
28
+ // demoUndirectedGraph();
29
+ // // console.log("================================================================");
30
+ // demoDirectedGraph();
31
+ // // console.log("================================================================");
32
+ // demoGraphGenerated();
33
+ // // console.log("================================================================");
34
+ // compareAllSortTypes();
35
+ // // console.log("===========================================================");
36
+ // perfQueue();
37
+ // // console.log("===========================================================");
38
+ // perfStack();
39
+ // // console.log("===========================================================");
40
+ // demoBst();
41
+ // // console.log("===========================================================");
42
+ // bstCompare();
43
+ // // console.log("===========================================================");
44
+ // demoHashtable();
package/.eslintrc.js DELETED
@@ -1,14 +0,0 @@
1
- module.exports = {
2
- root: true,
3
- parser: "@typescript-eslint/parser",
4
- plugins: ["@typescript-eslint", "prettier"],
5
- extends: [
6
- "eslint:recommended",
7
- "plugin:@typescript-eslint/recommended",
8
- "plugin:prettier/recommended",
9
- "prettier/@typescript-eslint",
10
- ],
11
- env: {
12
- node: true,
13
- },
14
- };
package/jest.config.js DELETED
@@ -1,4 +0,0 @@
1
- module.exports = {
2
- preset: "ts-jest",
3
- testEnvironment: "node",
4
- };
package/nodemon.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "watch": ["src"],
3
- "ext": ".ts,.js",
4
- "ignore": [],
5
- "exec": "ts-node ./src/index.ts"
6
- }
@@ -1,35 +0,0 @@
1
- import { factorial, memoizedFactorial } from "../algorithms/factorial";
2
- import { fibonacci, memoizedFibonacci } from "../algorithms/fibonacci";
3
- import { binarySearch } from "../algorithms/binary-search";
4
- import { transposeMatrix } from "../algorithms/transpose-matrix";
5
- import { transposeDirectedGraph } from "../data-structures/Graph/transposing/transposeDirectedGraph";
6
- import BFSIterationStrategy from "../data-structures/Graph/strategy/BFSIterationStrategy";
7
- import DFSIterationStrategy from "../data-structures/Graph/strategy/DFSIterationStrategy";
8
- import DijkstraIterationStrategy from "../data-structures/Graph/strategy/DijkstraIterationStrategy";
9
- import GraphIteratorBFS from "../data-structures/Graph/iterator/GraphIteratorBFS";
10
- import GraphIteratorDFS from "../data-structures/Graph/iterator/GraphIteratorDFS";
11
- import GraphIteratorDijkstra from "../data-structures/Graph/iterator/GraphIteratorDijkstra";
12
- import { hasPath } from "../data-structures/Graph/searching/hasPath";
13
- import { shortestPath } from "../data-structures/Graph/searching/shortestPath";
14
- import { presenterAdjacencyMatrix } from "../data-structures/Graph/presenter/presenterAdjacencyMatrix";
15
- import { presenterAdjacencyLists } from "../data-structures/Graph/presenter/presenterAdjacencyLists";
16
-
17
- export {
18
- binarySearch,
19
- factorial,
20
- memoizedFactorial,
21
- memoizedFibonacci,
22
- fibonacci,
23
- transposeMatrix,
24
- GraphIteratorDFS,
25
- presenterAdjacencyLists,
26
- presenterAdjacencyMatrix,
27
- hasPath,
28
- shortestPath,
29
- DijkstraIterationStrategy,
30
- DFSIterationStrategy,
31
- BFSIterationStrategy,
32
- GraphIteratorBFS,
33
- GraphIteratorDijkstra,
34
- transposeDirectedGraph,
35
- };
@@ -1,3 +0,0 @@
1
- import { EDGE_EXISTS_STATE, EDGE_NOT_EXISTS_STATE } from "../constants";
2
-
3
- export { EDGE_NOT_EXISTS_STATE, EDGE_EXISTS_STATE };
@@ -1,13 +0,0 @@
1
- import { generateRandomGraph } from "../data-structures/Graph/demo/generateRandomGraph";
2
- import { createLinkedList } from "../helpers/createLinkedList";
3
- import { createBinaryTree } from "../helpers/createBinaryTree";
4
- import { createGraph } from "../helpers/createGraph";
5
- import { createGraphFromMatrix } from "../helpers/createGraphFromMatrix";
6
-
7
- export {
8
- createGraph,
9
- createGraphFromMatrix,
10
- createBinaryTree,
11
- createLinkedList,
12
- generateRandomGraph,
13
- };
@@ -1,21 +0,0 @@
1
- import Queue from "../data-structures/Queue/Queue";
2
- import Stack from "../data-structures/Stack/Stack";
3
- import UndirectedGraph from "../data-structures/Graph/UndirectedGraph";
4
- import DirectedGraph from "../data-structures/Graph/DirectedGraph";
5
- import BinarySearchTree from "../data-structures/BinaryTree/BinarySearchTree/BinarySearchTree";
6
- import RandBinarySearchTree from "../data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchTree";
7
- import DoubleLinkedList from "../data-structures/LinkedList/DoubleLinkedList/DoubleLinkedList";
8
- import SingleLinkedList from "../data-structures/LinkedList/SingleLinkedList/SingleLinkedList";
9
- import LoopedArray from "../data-structures/LoopedArray/LoopedArray";
10
-
11
- export {
12
- Stack,
13
- Queue,
14
- SingleLinkedList,
15
- DoubleLinkedList,
16
- RandBinarySearchTree,
17
- BinarySearchTree,
18
- DirectedGraph,
19
- UndirectedGraph,
20
- LoopedArray,
21
- };
@@ -1,7 +0,0 @@
1
- import { bubbleSort } from "../algorithms/sorts/bubble-sort";
2
- import { selectSort } from "../algorithms/sorts/select-sort";
3
- import { mergeSort } from "../algorithms/sorts/merge-sort";
4
- import { insertionSort } from "../algorithms/sorts/insertion-sort";
5
- import { quickSort } from "../algorithms/sorts/quick-sort";
6
-
7
- export { bubbleSort, insertionSort, mergeSort, selectSort, quickSort };
@@ -1,53 +0,0 @@
1
- import { ArrayMatrix } from "../types/ArrayMatrix";
2
- import { EnumTreeTraversalType } from "../types/EnumTreeTraversalType";
3
- import { EnumBinarySearchTreeType } from "../types/EnumBinarySearchTreeType";
4
- import { EnumGraphTraversalType } from "../types/EnumGraphTraversalType";
5
- import { EnumGraphType } from "../types/EnumGraphType";
6
- import { EnumLinkedListType } from "../types/EnumLinkedListType";
7
- import { EnumRandomGenerationFormat } from "../types/EnumRandomGenerationFormat";
8
- import { EnumSortType } from "../types/EnumSortType";
9
- import { FnSort } from "../types/FnSort";
10
- import { FnCompareTwo } from "../types/FnCompareTwo";
11
- import { FnToMemoize } from "../types/FnToMemoize";
12
- import IArrayFacade from "../types/IArrayFacade";
13
- import IBiDirectIterator from "../types/IBiDirectIterator";
14
- import IBiDirectIterable from "../types/IBiDirectIterable";
15
- import IIterable from "../types/IIterable";
16
- import IIterator from "../types/IIterator";
17
- import IBinaryTree from "../types/IBinaryTree";
18
- import IConvertableToArray from "../types/IConvertableToArray";
19
- import IGraph from "../types/IGraph";
20
- import IGraphCreator from "../types/IGraphCreator";
21
- import IGraphIterationStrategy from "../types/IGraphIterationStrategy";
22
- import IGraphIterator from "../types/IGraphIterator";
23
- import ILinearStorage from "../types/ILinearStorage";
24
- import ILinearStorageRA from "../types/ILinearStorageRA";
25
- import ILinkedList from "../types/ILinkedList";
26
-
27
- export {
28
- IGraph,
29
- IGraphIterator,
30
- IGraphIterationStrategy,
31
- IIterator,
32
- IIterable,
33
- IGraphCreator,
34
- IBiDirectIterable,
35
- IBiDirectIterator,
36
- EnumGraphType,
37
- EnumSortType,
38
- FnSort,
39
- EnumGraphTraversalType,
40
- EnumTreeTraversalType,
41
- EnumBinarySearchTreeType,
42
- IBinaryTree,
43
- EnumLinkedListType,
44
- ILinkedList,
45
- ILinearStorage,
46
- ILinearStorageRA,
47
- IArrayFacade,
48
- IConvertableToArray,
49
- ArrayMatrix,
50
- FnCompareTwo,
51
- EnumRandomGenerationFormat,
52
- FnToMemoize,
53
- };
@@ -1,25 +0,0 @@
1
- import { binarySearch } from "../../../src/algorithms/binary-search";
2
-
3
- describe("Binary search", () => {
4
- it("should find in positive 100 elements", () => {
5
- const arr: Array<number> = [];
6
- for (let i = 0; i < 100; i++) arr.push(i + 1);
7
- const foundElement = binarySearch(arr, 97);
8
-
9
- expect(foundElement).toBe(96);
10
- });
11
-
12
- it("should find in negative 100 elements", () => {
13
- const arr: Array<number> = [];
14
- for (let i = 0; i < 100; i++) arr.push(-100 + i - 1);
15
- const foundElement = binarySearch(arr, -97);
16
-
17
- expect(foundElement).toBe(4);
18
- });
19
-
20
- it("should return null in empty list", () => {
21
- const arr: Array<number> = [];
22
-
23
- expect(binarySearch(arr, 10)).toBeNull();
24
- });
25
- });