@raikuxq/alg-ds 1.1.7 → 1.2.0
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.
- package/README.md +67 -78
- package/lib/{algorithms → app/algorithms}/binary-search.d.ts +0 -0
- package/lib/app/algorithms/binary-search.js +27 -0
- package/lib/{algorithms → app/algorithms}/factorial.d.ts +0 -0
- package/lib/{algorithms → app/algorithms}/factorial.js +1 -1
- package/lib/{algorithms → app/algorithms}/fibonacci.d.ts +0 -0
- package/lib/app/algorithms/fibonacci.js +17 -0
- package/lib/{data-structures/Graph → app/algorithms/graph}/iterator/AbstractGraphIterator.d.ts +0 -0
- package/lib/app/algorithms/graph/iterator/AbstractGraphIterator.js +83 -0
- package/lib/{data-structures/Graph → app/algorithms/graph}/iterator/GraphIteratorBFS.d.ts +0 -0
- package/lib/{data-structures/Graph → app/algorithms/graph}/iterator/GraphIteratorBFS.js +2 -2
- package/lib/{data-structures/Graph → app/algorithms/graph}/iterator/GraphIteratorDFS.d.ts +0 -0
- package/lib/{data-structures/Graph → app/algorithms/graph}/iterator/GraphIteratorDFS.js +2 -2
- package/lib/{data-structures/Graph → app/algorithms/graph}/iterator/GraphIteratorDijkstra.d.ts +0 -0
- package/lib/{data-structures/Graph → app/algorithms/graph}/iterator/GraphIteratorDijkstra.js +3 -5
- package/lib/{data-structures/Graph/strategy → app/algorithms/graph/iterator-strategy}/BFSIterationStrategy.d.ts +0 -0
- package/lib/{data-structures/Graph/strategy → app/algorithms/graph/iterator-strategy}/BFSIterationStrategy.js +1 -1
- package/lib/{data-structures/Graph/strategy → app/algorithms/graph/iterator-strategy}/DFSIterationStrategy.d.ts +0 -0
- package/lib/{data-structures/Graph/strategy → app/algorithms/graph/iterator-strategy}/DFSIterationStrategy.js +1 -1
- package/lib/{data-structures/Graph/strategy → app/algorithms/graph/iterator-strategy}/DijkstraIterationStrategy.d.ts +0 -0
- package/lib/{data-structures/Graph/strategy → app/algorithms/graph/iterator-strategy}/DijkstraIterationStrategy.js +1 -1
- package/lib/{data-structures/Graph → app/algorithms/graph}/presenter/presenterAdjacencyLists.d.ts +0 -0
- package/lib/{data-structures/Graph → app/algorithms/graph}/presenter/presenterAdjacencyLists.js +1 -1
- package/lib/{data-structures/Graph → app/algorithms/graph}/presenter/presenterAdjacencyMatrix.d.ts +2 -2
- package/lib/{data-structures/Graph → app/algorithms/graph}/presenter/presenterAdjacencyMatrix.js +1 -1
- package/lib/{data-structures/Graph → app/algorithms/graph}/searching/hasPath.d.ts +0 -0
- package/lib/{data-structures/Graph → app/algorithms/graph}/searching/hasPath.js +1 -1
- package/lib/{data-structures/Graph → app/algorithms/graph}/searching/shortestPath.d.ts +0 -0
- package/lib/{data-structures/Graph → app/algorithms/graph}/searching/shortestPath.js +1 -1
- package/lib/{data-structures/Graph → app/algorithms/graph}/transposing/transposeDirectedGraph.d.ts +0 -0
- package/lib/{data-structures/Graph → app/algorithms/graph}/transposing/transposeDirectedGraph.js +3 -3
- package/lib/{algorithms → app/algorithms}/memoize.d.ts +0 -0
- package/lib/{algorithms → app/algorithms}/memoize.js +1 -1
- package/lib/{algorithms → app/algorithms}/sorts/bubble-sort.d.ts +0 -0
- package/lib/{algorithms → app/algorithms}/sorts/bubble-sort.js +1 -1
- package/lib/{algorithms → app/algorithms}/sorts/insertion-sort.d.ts +0 -0
- package/lib/app/algorithms/sorts/insertion-sort.js +25 -0
- package/lib/{algorithms → app/algorithms}/sorts/merge-sort.d.ts +0 -0
- package/lib/app/algorithms/sorts/merge-sort.js +61 -0
- package/lib/{algorithms → app/algorithms}/sorts/quick-sort.d.ts +0 -0
- package/lib/{algorithms → app/algorithms}/sorts/quick-sort.js +1 -1
- package/lib/{algorithms → app/algorithms}/sorts/select-sort.d.ts +0 -0
- package/lib/{algorithms → app/algorithms}/sorts/select-sort.js +1 -1
- package/lib/app/algorithms/transpose-matrix.d.ts +5 -0
- package/lib/{algorithms → app/algorithms}/transpose-matrix.js +1 -1
- package/lib/{constants.d.ts → app/constants.d.ts} +0 -0
- package/lib/{constants.js → app/constants.js} +1 -1
- package/lib/{data-structures → app/data-structures}/BinaryTree/AbstractBinaryTree/AbstractBinaryNode.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/BinaryTree/AbstractBinaryTree/AbstractBinaryNode.js +1 -1
- package/lib/{data-structures → app/data-structures}/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.js +1 -1
- package/lib/{data-structures → app/data-structures}/BinaryTree/BinarySearchTree/BinarySearchNode.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/BinaryTree/BinarySearchTree/BinarySearchNode.js +1 -1
- package/lib/{data-structures → app/data-structures}/BinaryTree/BinarySearchTree/BinarySearchTree.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/BinaryTree/BinarySearchTree/BinarySearchTree.js +3 -3
- package/lib/{data-structures → app/data-structures}/BinaryTree/RandBinarySearchTree/RandBinarySearchNode.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/BinaryTree/RandBinarySearchTree/RandBinarySearchNode.js +1 -1
- package/lib/{data-structures → app/data-structures}/BinaryTree/RandBinarySearchTree/RandBinarySearchTree.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/BinaryTree/RandBinarySearchTree/RandBinarySearchTree.js +1 -1
- package/lib/app/data-structures/BinaryTree/_helpers/createBinaryTree.d.ts +6 -0
- package/lib/app/data-structures/BinaryTree/_helpers/createBinaryTree.js +22 -0
- package/lib/{data-structures → app/data-structures}/Graph/AbstractGraph.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/Graph/AbstractGraph.js +1 -1
- package/lib/{data-structures → app/data-structures}/Graph/DirectedGraph.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/Graph/DirectedGraph.js +1 -1
- package/lib/{data-structures → app/data-structures}/Graph/GraphEdge.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/Graph/GraphEdge.js +1 -1
- package/lib/{data-structures → app/data-structures}/Graph/UndirectedGraph.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/Graph/UndirectedGraph.js +1 -1
- package/lib/app/data-structures/Graph/_helpers/createGraph.d.ts +6 -0
- package/lib/app/data-structures/Graph/_helpers/createGraph.js +22 -0
- package/lib/app/data-structures/Graph/_helpers/createGraphFromMatrix.d.ts +7 -0
- package/lib/app/data-structures/Graph/_helpers/createGraphFromMatrix.js +42 -0
- package/lib/{data-structures/Graph/demo → app/data-structures/Graph/_helpers}/generateRandomGraph.d.ts +0 -0
- package/lib/app/data-structures/Graph/_helpers/generateRandomGraph.js +67 -0
- package/lib/{data-structures → app/data-structures}/HashTable/HashTable.d.ts +0 -0
- package/lib/app/data-structures/HashTable/HashTable.js +171 -0
- package/lib/{data-structures → app/data-structures}/HashTable/HashTableNode.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/HashTable/HashTableNode.js +1 -1
- package/lib/{data-structures → app/data-structures}/LinkedList/AbstractLinkedList/AbstractLinkedList.d.ts +0 -0
- package/lib/app/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedList.js +241 -0
- package/lib/{data-structures → app/data-structures}/LinkedList/AbstractLinkedList/AbstractLinkedNode.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/LinkedList/AbstractLinkedList/AbstractLinkedNode.js +1 -1
- package/lib/{data-structures → app/data-structures}/LinkedList/DoubleLinkedList/DoubleLinkedList.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/LinkedList/DoubleLinkedList/DoubleLinkedList.js +1 -1
- package/lib/{data-structures → app/data-structures}/LinkedList/DoubleLinkedList/DoubleLinkedNode.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/LinkedList/DoubleLinkedList/DoubleLinkedNode.js +1 -1
- package/lib/{data-structures → app/data-structures}/LinkedList/SingleLinkedList/SingleLinkedList.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/LinkedList/SingleLinkedList/SingleLinkedList.js +1 -1
- package/lib/{data-structures → app/data-structures}/LinkedList/SingleLinkedList/SingleLinkedNode.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/LinkedList/SingleLinkedList/SingleLinkedNode.js +1 -1
- package/lib/app/data-structures/LinkedList/_helpers/createLinkedList.d.ts +3 -0
- package/lib/app/data-structures/LinkedList/_helpers/createLinkedList.js +19 -0
- package/lib/{data-structures → app/data-structures}/LoopedArray/LoopedArray.d.ts +0 -0
- package/lib/app/data-structures/LoopedArray/LoopedArray.js +169 -0
- package/lib/{data-structures → app/data-structures}/Queue/Queue.d.ts +0 -0
- package/lib/app/data-structures/Queue/Queue.js +85 -0
- package/lib/{data-structures → app/data-structures}/Stack/Stack.d.ts +0 -0
- package/lib/app/data-structures/Stack/Stack.js +85 -0
- package/lib/{exceptions/IsEmptyException.d.ts → app/exceptions/CollectionIsEmptyException.d.ts} +1 -1
- package/lib/{exceptions/IsFullException.js → app/exceptions/CollectionIsEmptyException.js} +7 -7
- package/lib/{exceptions/IsFullException.d.ts → app/exceptions/CollectionIsFullException.d.ts} +1 -1
- package/lib/{exceptions/IsEmptyException.js → app/exceptions/CollectionIsFullException.js} +7 -7
- package/lib/{exceptions → app/exceptions}/IndexOutOfBoundsException.d.ts +0 -0
- package/lib/{exceptions → app/exceptions}/IndexOutOfBoundsException.js +1 -1
- package/lib/{exceptions → app/exceptions}/IsAlreadyExistsException.d.ts +0 -0
- package/lib/{exceptions → app/exceptions}/IsAlreadyExistsException.js +1 -1
- package/lib/{exceptions → app/exceptions}/IsNotFoundException.d.ts +0 -0
- package/lib/{exceptions → app/exceptions}/IsNotFoundException.js +1 -1
- package/lib/{exceptions/IllegalCapacityException.d.ts → app/exceptions/ValueOutOfRangeException.d.ts} +1 -1
- package/lib/{exceptions/IllegalCapacityException.js → app/exceptions/ValueOutOfRangeException.js} +7 -7
- package/lib/{exceptions → app/exceptions}/base/IllegalArgumentException.d.ts +0 -0
- package/lib/{exceptions → app/exceptions}/base/IllegalArgumentException.js +1 -1
- package/lib/{exceptions → app/exceptions}/base/IllegalStateException.d.ts +0 -0
- package/lib/{exceptions → app/exceptions}/base/IllegalStateException.js +1 -1
- package/lib/{types → app/types}/EnumBinarySearchTreeType.d.ts +0 -0
- package/lib/{types → app/types}/EnumBinarySearchTreeType.js +1 -1
- package/lib/app/types/EnumGraphTraversalType.d.ts +5 -0
- package/lib/app/types/EnumGraphTraversalType.js +10 -0
- package/lib/{types → app/types}/EnumGraphType.d.ts +0 -0
- package/lib/{types → app/types}/EnumGraphType.js +1 -1
- package/lib/{types → app/types}/EnumLinkedListType.d.ts +0 -0
- package/lib/{types → app/types}/EnumLinkedListType.js +1 -1
- package/lib/{types → app/types}/EnumRandomGenerationFormat.d.ts +0 -0
- package/lib/{types → app/types}/EnumRandomGenerationFormat.js +1 -1
- package/lib/app/types/EnumSortType.d.ts +7 -0
- package/lib/app/types/EnumSortType.js +12 -0
- package/lib/{types → app/types}/EnumTreeTraversalType.d.ts +0 -0
- package/lib/{types → app/types}/EnumTreeTraversalType.js +1 -1
- package/lib/{types → app/types}/FnCompareTwo.d.ts +0 -0
- package/lib/{types → app/types}/FnCompareTwo.js +1 -1
- package/lib/{types → app/types}/FnToMemoize.d.ts +0 -0
- package/lib/{types → app/types}/FnToMemoize.js +1 -1
- package/lib/{types → app/types}/IArrayFacade.d.ts +0 -0
- package/lib/{types → app/types}/IArrayFacade.js +1 -1
- package/lib/{types → app/types}/IBiDirectIterable.d.ts +0 -0
- package/lib/{types → app/types}/IBiDirectIterable.js +1 -1
- package/lib/{types → app/types}/IBiDirectIterator.d.ts +0 -0
- package/lib/{types → app/types}/IBiDirectIterator.js +1 -1
- package/lib/{types → app/types}/IBinaryTree.d.ts +0 -0
- package/lib/{types → app/types}/IBinaryTree.js +1 -1
- package/lib/{types → app/types}/IConvertableToArray.d.ts +0 -0
- package/lib/{types → app/types}/IConvertableToArray.js +1 -1
- package/lib/{types → app/types}/IGraph.d.ts +0 -0
- package/lib/{types → app/types}/IGraph.js +1 -1
- package/lib/{types → app/types}/IGraphIterationStrategy.d.ts +0 -0
- package/lib/{types → app/types}/IGraphIterationStrategy.js +1 -1
- package/lib/{types → app/types}/IGraphIterator.d.ts +0 -0
- package/lib/{types → app/types}/IGraphIterator.js +1 -1
- package/lib/{types → app/types}/IIterable.d.ts +0 -0
- package/lib/{types → app/types}/IIterable.js +1 -1
- package/lib/{types → app/types}/IIterator.d.ts +0 -0
- package/lib/{types → app/types}/IIterator.js +1 -1
- package/lib/{types → app/types}/IKeyValueStorage.d.ts +0 -0
- package/lib/{types → app/types}/IKeyValueStorage.js +1 -1
- package/lib/{types → app/types}/ILinearStorage.d.ts +0 -0
- package/lib/{types → app/types}/ILinearStorage.js +1 -1
- package/lib/{types → app/types}/ILinearStorageRA.d.ts +0 -0
- package/lib/{types → app/types}/ILinearStorageRA.js +1 -1
- package/lib/{types → app/types}/ILinkedList.d.ts +0 -0
- package/lib/{types → app/types}/ILinkedList.js +1 -1
- package/lib/app/types/TypeArrayMatrix.d.ts +1 -0
- package/lib/app/types/TypeArrayMatrix.js +3 -0
- package/lib/{utils.d.ts → app/utils.d.ts} +4 -0
- package/lib/{utils.js → app/utils.js} +8 -2
- package/lib/exports/algorithms.d.ts +15 -15
- package/lib/exports/algorithms.js +16 -16
- package/lib/exports/constants.d.ts +1 -1
- package/lib/exports/constants.js +2 -2
- package/lib/exports/data-structures.d.ts +10 -10
- package/lib/exports/data-structures.js +11 -11
- package/lib/exports/helpers.d.ts +5 -5
- package/lib/exports/helpers.js +6 -6
- package/lib/exports/sorts.d.ts +5 -5
- package/lib/exports/sorts.js +6 -6
- package/lib/exports/types.d.ts +16 -0
- package/lib/exports/types.js +34 -0
- package/lib/exports/utils.d.ts +2 -2
- package/lib/exports/utils.js +3 -3
- package/lib/exports.d.ts +47 -46
- package/lib/exports.js +51 -49
- package/lib/index.js +1 -2
- package/package.json +11 -6
- package/lib/algorithms/binary-search.js +0 -27
- package/lib/algorithms/fibonacci.js +0 -17
- package/lib/algorithms/sorts/insertion-sort.js +0 -25
- package/lib/algorithms/sorts/merge-sort.js +0 -61
- package/lib/algorithms/transpose-matrix.d.ts +0 -5
- package/lib/data-structures/Graph/demo/generateRandomGraph.js +0 -66
- package/lib/data-structures/Graph/iterator/AbstractGraphIterator.js +0 -90
- package/lib/data-structures/HashTable/HashTable.js +0 -171
- package/lib/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedList.js +0 -241
- package/lib/data-structures/LoopedArray/LoopedArray.js +0 -169
- package/lib/data-structures/Queue/Queue.js +0 -85
- package/lib/data-structures/Stack/Stack.js +0 -85
- package/lib/helpers/createBinaryTree.d.ts +0 -6
- package/lib/helpers/createBinaryTree.js +0 -22
- package/lib/helpers/createGraph.d.ts +0 -6
- package/lib/helpers/createGraph.js +0 -24
- package/lib/helpers/createGraphFromMatrix.d.ts +0 -7
- package/lib/helpers/createGraphFromMatrix.js +0 -42
- package/lib/helpers/createLinkedList.d.ts +0 -3
- package/lib/helpers/createLinkedList.js +0 -21
- package/lib/types/ArrayMatrix.d.ts +0 -1
- package/lib/types/ArrayMatrix.js +0 -3
package/README.md
CHANGED
|
@@ -2,30 +2,15 @@ Common algorithms and data structures.
|
|
|
2
2
|
|
|
3
3
|
Written in TypeScript, tested with Jest.
|
|
4
4
|
|
|
5
|
+
# Documentation
|
|
6
|
+
Documentation app available here: [https://raikuxq-algorithms.netlify.app/guide](https://raikuxq-algorithms.netlify.app/guide)
|
|
7
|
+
|
|
5
8
|
|
|
6
9
|
# Usage as package
|
|
7
10
|
Install by using any of these commands:
|
|
8
11
|
+ `yarn add @raikuxq/alg-ds`
|
|
9
12
|
+ `npm install @raikuxq/alg-ds --save`
|
|
10
13
|
|
|
11
|
-
## Import from root
|
|
12
|
-
`import { <anything> } from '@raikuxq/alg-ds'`
|
|
13
|
-
|
|
14
|
-
## Import from sub-paths
|
|
15
|
-
### Data structures
|
|
16
|
-
`import {Stack, Queue, SingleLinkedList, DoubleLinkedList, RandBinarySearchTree, BinarySearchTree, DirectedGraph, UndirectedGraph, LoopedArray, HashTable, } from '@raikuxq/alg-ds/lib/exports/data-structures'`
|
|
17
|
-
### Sorting algorithms
|
|
18
|
-
`import {bubbleSort, insertionSort, mergeSort, selectSort, quickSort} from '@raikuxq/alg-ds/lib/exports/data-structures `
|
|
19
|
-
### Other algorithms
|
|
20
|
-
`import {binarySearch, factorial, memoizedFactorial, memoizedFibonacci, fibonacci, transposeMatrix, GraphIteratorDFS, presenterAdjacencyLists, presenterAdjacencyMatrix, hasPath, shortestPath, DijkstraIterationStrategy, DFSIterationStrategy, BFSIterationStrategy, GraphIteratorBFS, GraphIteratorDijkstra, transposeDirectedGraph} from '@raikuxq/alg-ds/lib/exports/algorithms'`
|
|
21
|
-
### Helpers
|
|
22
|
-
`import {createGraph, createGraphFromMatrix, createBinaryTree, createLinkedList, generateRandomGraph} from '@raikuxq/alg-ds/lib/exports/helpers`
|
|
23
|
-
### Utils
|
|
24
|
-
`import {perf, getMinIndex, getMinIndexFromIndex, memoize, perfAsync, roundNumber, randomizeNumberInRange, swapArrayItems} from '@raikuxq/alg-ds/lib/exports/utils'`
|
|
25
|
-
### Constants
|
|
26
|
-
`import {EDGE_NOT_EXISTS_STATE, EDGE_EXISTS_STATE} from '@raikuxq/alg-ds/lib/exports/constants'`
|
|
27
|
-
|
|
28
|
-
|
|
29
14
|
|
|
30
15
|
# Usage as repository
|
|
31
16
|
|
|
@@ -46,6 +31,8 @@ Clone this repository and install dependencies by using `yarn` command.
|
|
|
46
31
|
|
|
47
32
|
# Navigation
|
|
48
33
|
+ [Algorithms](#algorithms)
|
|
34
|
+
+ [Utils](#utils)
|
|
35
|
+
+ [Math](#math)
|
|
49
36
|
+ [Sorting algorithms](#sorting-algorithms)
|
|
50
37
|
+ [Linear data structures](#linear-data-structures)
|
|
51
38
|
+ [Linked list](#linked-list)
|
|
@@ -60,28 +47,30 @@ Clone this repository and install dependencies by using `yarn` command.
|
|
|
60
47
|
|
|
61
48
|
# Algorithms
|
|
62
49
|
|
|
63
|
-
##
|
|
64
|
-
[memoize](src/algorithms/memoize.ts) — Memoization util function.
|
|
50
|
+
## Utils
|
|
51
|
+
[memoize](src/app/algorithms/memoize.ts) — Memoization util function.
|
|
65
52
|
|
|
66
|
-
|
|
53
|
+
## Searching
|
|
54
|
+
[binary-search](src/app/algorithms/binary-search.ts) [[ tests ](test/unit/algorithms/binary-search.test.ts)] — Binary searching algorithm. Time: O(log(n)).
|
|
67
55
|
|
|
68
|
-
|
|
56
|
+
## Math
|
|
57
|
+
[factorial](src/app/algorithms/factorial.ts) [[ tests ](test/unit/algorithms/factorial.test.ts)] — Recursive O(n!) and memoized O(n) factorial implementation.
|
|
69
58
|
|
|
70
|
-
[fibonacci](src/algorithms/fibonacci.ts) [[ tests ](test/unit/algorithms/fibonacci.test.ts)] — Recursive O(n!) and memoized O(n) factorial implementation.
|
|
59
|
+
[fibonacci](src/app/algorithms/fibonacci.ts) [[ tests ](test/unit/algorithms/fibonacci.test.ts)] — Recursive O(n!) and memoized O(n) factorial implementation.
|
|
71
60
|
|
|
72
|
-
[transpose-matrix](src/algorithms/transpose-matrix.ts) [[ tests ](test/unit/algorithms/transpose-matrix.test.ts)] — Transpose N*N matrix util function.
|
|
61
|
+
[transpose-matrix](src/app/algorithms/transpose-matrix.ts) [[ tests ](test/unit/algorithms/transpose-matrix.test.ts)] — Transpose N*N matrix util function.
|
|
73
62
|
|
|
74
63
|
|
|
75
64
|
## Sorting algorithms
|
|
76
|
-
[bubble-sort](src/algorithms/sorts/bubble-sort.ts) [[ tests ](test/unit/algorithms/sorts.test.ts)] — Time: O(n^2) worst, O(n^2) avg, O(n) best. Memory: O(1) worst.
|
|
65
|
+
[bubble-sort](src/app/algorithms/sorts/bubble-sort.ts) [[ tests ](test/unit/algorithms/sorts.test.ts)] — Time: O(n^2) worst, O(n^2) avg, O(n) best. Memory: O(1) worst.
|
|
77
66
|
|
|
78
|
-
[selection-sort](src/algorithms/sorts/select-sort.ts) [[ tests ](test/unit/algorithms/sorts.test.ts)] — Time: O(n^2) worst, O(n^2) avg, O(n^2) best. Memory: O(1) worst.
|
|
67
|
+
[selection-sort](src/app/algorithms/sorts/select-sort.ts) [[ tests ](test/unit/algorithms/sorts.test.ts)] — Time: O(n^2) worst, O(n^2) avg, O(n^2) best. Memory: O(1) worst.
|
|
79
68
|
|
|
80
|
-
[insertion-sort](src/algorithms/sorts/insertion-sort.ts) [[ tests ](test/unit/algorithms/sorts.test.ts)] — Time: O(n^2) worst, O(n^2) avg, O(n) best. Memory: O(1) worst.
|
|
69
|
+
[insertion-sort](src/app/algorithms/sorts/insertion-sort.ts) [[ tests ](test/unit/algorithms/sorts.test.ts)] — Time: O(n^2) worst, O(n^2) avg, O(n) best. Memory: O(1) worst.
|
|
81
70
|
|
|
82
|
-
[merge-sort](src/algorithms/sorts/merge-sort.ts) [[ tests ](test/unit/algorithms/sorts.test.ts)] — Time: O(n*log(n)) worst, O(n*log(n)) avg, O(n*log(n)) best. Memory: O(n) worst.
|
|
71
|
+
[merge-sort](src/app/algorithms/sorts/merge-sort.ts) [[ tests ](test/unit/algorithms/sorts.test.ts)] — Time: O(n*log(n)) worst, O(n*log(n)) avg, O(n*log(n)) best. Memory: O(n) worst.
|
|
83
72
|
|
|
84
|
-
[quick-sort](src/algorithms/sorts/quick-sort.ts) [[ tests ](test/unit/algorithms/sorts.test.ts)] — Time: O(n^2) worst, O(n*log(n)) avg, O(n*log(n)) best. Memory: O(1) worst.
|
|
73
|
+
[quick-sort](src/app/algorithms/sorts/quick-sort.ts) [[ tests ](test/unit/algorithms/sorts.test.ts)] — Time: O(n^2) worst, O(n*log(n)) avg, O(n*log(n)) best. Memory: O(1) worst.
|
|
85
74
|
|
|
86
75
|
|
|
87
76
|
|
|
@@ -90,57 +79,57 @@ Clone this repository and install dependencies by using `yarn` command.
|
|
|
90
79
|
# Linear data structures
|
|
91
80
|
|
|
92
81
|
### Interfaces
|
|
93
|
-
[ILinearStorage](src/types/ILinearStorage.ts) — Contains common methods of linear data structures.
|
|
82
|
+
[ILinearStorage](src/app/types/ILinearStorage.ts) — Contains common methods of linear data structures.
|
|
94
83
|
|
|
95
|
-
[ILinearStorageRA](src/types/ILinearStorageRA.ts) — Allows random access (from end, from start, by index).
|
|
96
|
-
Extends [ILinearStorage](src/types/ILinearStorage.ts) interface.
|
|
84
|
+
[ILinearStorageRA](src/app/types/ILinearStorageRA.ts) — Allows random access (from end, from start, by index).
|
|
85
|
+
Extends [ILinearStorage](src/app/types/ILinearStorage.ts) interface.
|
|
97
86
|
|
|
98
|
-
[IConvertableToArray](src/types/IConvertableToArray.ts) — Contain methods for converting from/into array.
|
|
87
|
+
[IConvertableToArray](src/app/types/IConvertableToArray.ts) — Contain methods for converting from/into array.
|
|
99
88
|
|
|
100
89
|
|
|
101
90
|
## Linked List
|
|
102
91
|
|
|
103
92
|
### Interfaces
|
|
104
|
-
[ILinkedList](src/types/ILinkedList.ts) — Contains basic linked lists operations.
|
|
105
|
-
Extends [ILinearStorageRA](src/types/ILinearStorageRA.ts) and [IConvertableToArray](src/types/IConvertableToArray.ts) interface.
|
|
93
|
+
[ILinkedList](src/app/types/ILinkedList.ts) — Contains basic linked lists operations.
|
|
94
|
+
Extends [ILinearStorageRA](src/app/types/ILinearStorageRA.ts) and [IConvertableToArray](src/app/types/IConvertableToArray.ts) interface.
|
|
106
95
|
|
|
107
96
|
### Implementation
|
|
108
|
-
[AbstractLinkedList](src/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedList.ts) — Common logic for both single and double linked lists.
|
|
109
|
-
Implements [ILinearStorageRA](src/types/ILinearStorageRA.ts) interface.
|
|
97
|
+
[AbstractLinkedList](src/app/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedList.ts) — Common logic for both single and double linked lists.
|
|
98
|
+
Implements [ILinearStorageRA](src/app/types/ILinearStorageRA.ts) interface.
|
|
110
99
|
|
|
111
|
-
[SingleLinkedList](src/data-structures/LinkedList/SingleLinkedList/SingleLinkedList.ts)
|
|
100
|
+
[SingleLinkedList](src/app/data-structures/LinkedList/SingleLinkedList/SingleLinkedList.ts)
|
|
112
101
|
[ [ tests ] ](test/unit/data-structures/linked-list/linked-list.test.ts)
|
|
113
102
|
— Extends abstract linked list with implementation of one-way linking.
|
|
114
|
-
Implements [IIterable](src/types/IIterable.ts) interface.
|
|
103
|
+
Implements [IIterable](src/app/types/IIterable.ts) interface.
|
|
115
104
|
|
|
116
|
-
[DoubleLinkedList](src/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedList.ts)
|
|
105
|
+
[DoubleLinkedList](src/app/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedList.ts)
|
|
117
106
|
[ [ tests ] ](test/unit/data-structures/linked-list/linked-list.test.ts)
|
|
118
107
|
— Extends abstract linked list with implementation of two-way linking.
|
|
119
|
-
Implements [IBiDirectIterable](src/types/IBiDirectIterable.ts) interface.
|
|
108
|
+
Implements [IBiDirectIterable](src/app/types/IBiDirectIterable.ts) interface.
|
|
120
109
|
|
|
121
110
|
|
|
122
111
|
## Looped Array
|
|
123
112
|
|
|
124
113
|
### Interfaces
|
|
125
|
-
[IArrayFacade](src/types/IArrayFacade.ts) — Contains basic array operations.
|
|
126
|
-
Extends [ILinearStorageRA](src/types/ILinearStorageRA.ts) interface.
|
|
127
|
-
Extends [IConvertableToArray](src/types/IConvertableToArray.ts) interface.
|
|
114
|
+
[IArrayFacade](src/app/types/IArrayFacade.ts) — Contains basic array operations.
|
|
115
|
+
Extends [ILinearStorageRA](src/app/types/ILinearStorageRA.ts) interface.
|
|
116
|
+
Extends [IConvertableToArray](src/app/types/IConvertableToArray.ts) interface.
|
|
128
117
|
|
|
129
118
|
### Implementation
|
|
130
|
-
[LoopedArray](src/data-structures/LoopedArray/LoopedArray.ts)[ [ tests ]](test/unit/data-structures/looped-array/looped-array.test.ts)
|
|
119
|
+
[LoopedArray](src/app/data-structures/LoopedArray/LoopedArray.ts)[ [ tests ]](test/unit/data-structures/looped-array/looped-array.test.ts)
|
|
131
120
|
— Overwrites data on capacity overflow.
|
|
132
121
|
|
|
133
122
|
## Stack
|
|
134
123
|
|
|
135
124
|
### Implementation
|
|
136
|
-
[Stack](src/data-structures/Stack/Stack.ts) [[ tests ](test/unit/data-structures/stack/stack.test.ts)]
|
|
137
|
-
— LIFO data structure. Implements [ILinearStorage](src/types/ILinearStorage.ts) interface.
|
|
125
|
+
[Stack](src/app/data-structures/Stack/Stack.ts) [[ tests ](test/unit/data-structures/stack/stack.test.ts)]
|
|
126
|
+
— LIFO data structure. Implements [ILinearStorage](src/app/types/ILinearStorage.ts) interface.
|
|
138
127
|
|
|
139
128
|
## Queue
|
|
140
129
|
|
|
141
130
|
### Implementation
|
|
142
|
-
[Queue](src/data-structures/Queue/Queue.ts) [[ tests ](test/unit/data-structures/queue/queue.test.ts)]
|
|
143
|
-
— FIFO data structure. Implements [ILinearStorage](src/types/ILinearStorage.ts) interface.
|
|
131
|
+
[Queue](src/app/data-structures/Queue/Queue.ts) [[ tests ](test/unit/data-structures/queue/queue.test.ts)]
|
|
132
|
+
— FIFO data structure. Implements [ILinearStorage](src/app/types/ILinearStorage.ts) interface.
|
|
144
133
|
|
|
145
134
|
|
|
146
135
|
|
|
@@ -148,96 +137,96 @@ Extends [IConvertableToArray](src/types/IConvertableToArray.ts) interface.
|
|
|
148
137
|
|
|
149
138
|
## Hash Table
|
|
150
139
|
### Interfaces
|
|
151
|
-
[IKeyValueStorage](src/types/IKeyValueStorage.ts) — Contains basic key-value storages operations.
|
|
140
|
+
[IKeyValueStorage](src/app/types/IKeyValueStorage.ts) — Contains basic key-value storages operations.
|
|
152
141
|
|
|
153
142
|
### Implementation
|
|
154
|
-
[HashTableNode](src/data-structures/HashTable/HashTableNode.ts) — Contains key, data and isDeleted properties.
|
|
143
|
+
[HashTableNode](src/app/data-structures/HashTable/HashTableNode.ts) — Contains key, data and isDeleted properties.
|
|
155
144
|
|
|
156
|
-
[HashTable](src/data-structures/HashTable/HashTable.ts) [ [ tests ] ](test/unit/data-structures/hash-table/hash-table.test.ts) — Implementation of open addressing hash table using quadratic probing
|
|
145
|
+
[HashTable](src/app/data-structures/HashTable/HashTable.ts) [ [ tests ] ](test/unit/data-structures/hash-table/hash-table.test.ts) — Implementation of open addressing hash table using quadratic probing
|
|
157
146
|
|
|
158
147
|
|
|
159
148
|
|
|
160
149
|
## Graph
|
|
161
150
|
### Interfaces
|
|
162
|
-
[IGraph](src/types/IGraph.ts) — Contains basic graph operations.
|
|
151
|
+
[IGraph](src/app/types/IGraph.ts) — Contains basic graph operations.
|
|
163
152
|
|
|
164
|
-
[IGraphIterator](src/types/IGraphIterator.ts) — Extends default iterator with init and getPath methods.
|
|
153
|
+
[IGraphIterator](src/app/types/IGraphIterator.ts) — Extends default iterator with init and getPath methods.
|
|
165
154
|
|
|
166
|
-
[IGraphIterationStrategy](src/types/IGraphIterationStrategy.ts) — Iteration strategies which are used in shortest-path, has-path.
|
|
155
|
+
[IGraphIterationStrategy](src/app/types/IGraphIterationStrategy.ts) — Iteration strategies which are used in shortest-path, has-path.
|
|
167
156
|
|
|
168
157
|
### Implementation
|
|
169
|
-
[GraphEdge](src/data-structures/Graph/GraphEdge.ts) — Contains from/to links and edge weight.
|
|
158
|
+
[GraphEdge](src/app/data-structures/Graph/GraphEdge.ts) — Contains from/to links and edge weight.
|
|
170
159
|
|
|
171
|
-
[AbstractGraph](src/data-structures/Graph/AbstractGraph.ts) — Common logic for both directed and undirected graphs.
|
|
160
|
+
[AbstractGraph](src/app/data-structures/Graph/AbstractGraph.ts) — Common logic for both directed and undirected graphs.
|
|
172
161
|
|
|
173
162
|
|
|
174
|
-
[DirectedGraph](src/data-structures/Graph/DirectedGraph.ts) [ [ tests ] ](test/unit/data-structures/graph/graph.test.ts)
|
|
163
|
+
[DirectedGraph](src/app/data-structures/Graph/DirectedGraph.ts) [ [ tests ] ](test/unit/data-structures/graph/graph.test.ts)
|
|
175
164
|
— In case of directed graph A->B and B->A edges are not the same.
|
|
176
165
|
|
|
177
|
-
[UndirectedGraph](src/data-structures/Graph/UndirectedGraph.ts) [ [ tests ] ](test/unit/data-structures/graph/graph.test.ts)
|
|
166
|
+
[UndirectedGraph](src/app/data-structures/Graph/UndirectedGraph.ts) [ [ tests ] ](test/unit/data-structures/graph/graph.test.ts)
|
|
178
167
|
— In case of undirected graph A->B and B->A are equal.
|
|
179
168
|
|
|
180
169
|
|
|
181
170
|
### Graph Iterators
|
|
182
171
|
|
|
183
|
-
[BreadthFirstSearchIterator](src/
|
|
172
|
+
[BreadthFirstSearchIterator](src/app/algorithms/graph/iterator/GraphIteratorBFS.ts)
|
|
184
173
|
— Traversal method for unweighted graphs, built on queue.
|
|
185
174
|
|
|
186
|
-
[DepthFirstSearchIterator](src/
|
|
175
|
+
[DepthFirstSearchIterator](src/app/algorithms/graph/iterator/GraphIteratorDFS.ts)
|
|
187
176
|
— Traversal method for unweighted graphs, built on stack.
|
|
188
177
|
|
|
189
|
-
[DijkstraMethodIterator](src/
|
|
178
|
+
[DijkstraMethodIterator](src/app/algorithms/graph/iterator/GraphIteratorDijkstra.ts)
|
|
190
179
|
— Traversal method for weighted graphs, built on finding the minimal cost.
|
|
191
180
|
|
|
192
181
|
|
|
193
182
|
### Graph Presenter
|
|
194
|
-
[presenter-adjacency-lists](src/
|
|
183
|
+
[presenter-adjacency-lists](src/app/algorithms/graph/presenter/presenterAdjacencyLists.ts) [[ tests ](test/unit/data-structures/graph/graph.presenter.lists.test.ts)]
|
|
195
184
|
— Representation of graph as an adjacency list (using Map).
|
|
196
185
|
|
|
197
|
-
[presenter-adjacency-matrix](src/
|
|
186
|
+
[presenter-adjacency-matrix](src/app/algorithms/graph/presenter/presenterAdjacencyMatrix.ts) [[ tests ](test/unit/data-structures/graph/graph.presenter.matrix.test.ts)]
|
|
198
187
|
— Representation of graph as an adjacency matrix (using Array N*N).
|
|
199
188
|
|
|
200
189
|
|
|
201
190
|
### Graph Searching
|
|
202
|
-
[has-path (BFS/DFS)](src/
|
|
191
|
+
[has-path (BFS/DFS)](src/app/algorithms/graph/searching/hasPath.ts) [[ tests ](test/unit/data-structures/graph/graph.has-path.test.ts)]
|
|
203
192
|
— Search for the existence of a path between two vertices.
|
|
204
193
|
|
|
205
|
-
[shortest-path (BFS/Dijkstra)](src/
|
|
194
|
+
[shortest-path (BFS/Dijkstra)](src/app/algorithms/graph/searching/shortestPath.ts) [[ tests ](test/unit/data-structures/graph/graph.shortest-path.test.ts)]
|
|
206
195
|
— Search for one of several shortest paths between two vertices.
|
|
207
196
|
|
|
208
197
|
### Graph Creators
|
|
209
|
-
[create-graph-from-matrix](src/
|
|
198
|
+
[create-graph-from-matrix](src/app/data-structures/Graph/_helpers/createGraphFromMatrix.ts) [[ tests ](test/unit/data-structures/graph/graph.create-from-matrix.test.ts)]
|
|
210
199
|
— Convert a matrix N*N into a graph instance.
|
|
211
200
|
|
|
212
201
|
|
|
213
202
|
### Graph Transposing
|
|
214
|
-
[transpose-directed-graph](src/
|
|
203
|
+
[transpose-directed-graph](src/app/algorithms/graph/transposing/transposeDirectedGraph.ts) [ [ tests ](test/unit/data-structures/graph/graph.transpose.test.ts)]
|
|
215
204
|
— Transpose a directed graph (undirected graphs are symmetrical already).
|
|
216
205
|
|
|
217
206
|
|
|
218
207
|
|
|
219
208
|
## Binary trees
|
|
220
|
-
[IBinaryTree](src/types/IBinaryTree.ts) — Contains basic binary tree operations.
|
|
209
|
+
[IBinaryTree](src/app/types/IBinaryTree.ts) — Contains basic binary tree operations.
|
|
221
210
|
|
|
222
211
|
### Implementation
|
|
223
212
|
|
|
224
|
-
[AbstractBinaryNode](src/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryNode.ts) — Contains left/right/parent links and node data.
|
|
213
|
+
[AbstractBinaryNode](src/app/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryNode.ts) — Contains left/right/parent links and node data.
|
|
225
214
|
|
|
226
|
-
[AbstractBinaryTree](src/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.ts) — Common logic for all types of binary trees.
|
|
215
|
+
[AbstractBinaryTree](src/app/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.ts) — Common logic for all types of binary trees.
|
|
227
216
|
|
|
228
217
|
|
|
229
|
-
[BinarySearchNode](src/data-structures/BinaryTree/BinarySearchTree/BinarySearchNode.ts) — Same as abstract binary node.
|
|
218
|
+
[BinarySearchNode](src/app/data-structures/BinaryTree/BinarySearchTree/BinarySearchNode.ts) — Same as abstract binary node.
|
|
230
219
|
|
|
231
|
-
[BinarySearchTree](src/data-structures/BinaryTree/BinarySearchTree/BinarySearchTree.ts) — Implementation of unbalanced binary search tree.
|
|
220
|
+
[BinarySearchTree](src/app/data-structures/BinaryTree/BinarySearchTree/BinarySearchTree.ts) — Implementation of unbalanced binary search tree.
|
|
232
221
|
Each node in left subtree is smaller and each node in right subtree is larger than the node data.
|
|
233
|
-
Extends [AbstractSearchTree](src/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.ts).
|
|
222
|
+
Extends [AbstractSearchTree](src/app/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.ts).
|
|
234
223
|
|
|
235
224
|
|
|
236
225
|
|
|
237
|
-
[RandBinarySearchNode](src/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchNode.ts) — Have a rank attribute.
|
|
238
|
-
Extends [BinarySearchNode](src/data-structures/BinaryTree/BinarySearchTree/BinarySearchNode.ts).
|
|
226
|
+
[RandBinarySearchNode](src/app/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchNode.ts) — Have a rank attribute.
|
|
227
|
+
Extends [BinarySearchNode](src/app/data-structures/BinaryTree/BinarySearchTree/BinarySearchNode.ts).
|
|
239
228
|
|
|
240
|
-
[RandBinarySearchTree](src/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchTree.ts)
|
|
229
|
+
[RandBinarySearchTree](src/app/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchTree.ts)
|
|
241
230
|
— Implementation of randomized binary search tree, which gives expected log(N) height.
|
|
242
231
|
Insertion have a 1/N+1 probability of inserting into root.
|
|
243
|
-
Extends [BinarySearchTree](src/data-structures/BinaryTree/BinarySearchTree/BinarySearchTree.ts).
|
|
232
|
+
Extends [BinarySearchTree](src/app/data-structures/BinaryTree/BinarySearchTree/BinarySearchTree.ts).
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.binarySearch = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Find element's index in sorted array
|
|
6
|
+
* Time complexity: O(log(n))
|
|
7
|
+
*/
|
|
8
|
+
exports.binarySearch = function (elements, searchElement) {
|
|
9
|
+
var length = elements.length;
|
|
10
|
+
var leftIndex = 0;
|
|
11
|
+
var rightIndex = length - 1;
|
|
12
|
+
while (leftIndex <= rightIndex) {
|
|
13
|
+
var midIndex = Math.ceil((leftIndex + rightIndex) / 2);
|
|
14
|
+
var midEl = elements[midIndex];
|
|
15
|
+
if (searchElement == midEl) {
|
|
16
|
+
return midIndex;
|
|
17
|
+
}
|
|
18
|
+
else if (midEl > searchElement) {
|
|
19
|
+
rightIndex = midIndex - 1;
|
|
20
|
+
}
|
|
21
|
+
else if (midEl < searchElement) {
|
|
22
|
+
leftIndex = midIndex + 1;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmluYXJ5LXNlYXJjaC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9hcHAvYWxnb3JpdGhtcy9iaW5hcnktc2VhcmNoLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBOzs7R0FHRztBQUNVLFFBQUEsWUFBWSxHQUFHLFVBQzFCLFFBQXVCLEVBQ3ZCLGFBQXFCO0lBRXJCLElBQU0sTUFBTSxHQUFXLFFBQVEsQ0FBQyxNQUFNLENBQUM7SUFFdkMsSUFBSSxTQUFTLEdBQUcsQ0FBQyxDQUFDO0lBQ2xCLElBQUksVUFBVSxHQUFXLE1BQU0sR0FBRyxDQUFDLENBQUM7SUFFcEMsT0FBTyxTQUFTLElBQUksVUFBVSxFQUFFO1FBQzlCLElBQU0sUUFBUSxHQUFXLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQyxTQUFTLEdBQUcsVUFBVSxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUM7UUFDakUsSUFBTSxLQUFLLEdBQVcsUUFBUSxDQUFDLFFBQVEsQ0FBQyxDQUFDO1FBRXpDLElBQUksYUFBYSxJQUFJLEtBQUssRUFBRTtZQUMxQixPQUFPLFFBQVEsQ0FBQztTQUNqQjthQUFNLElBQUksS0FBSyxHQUFHLGFBQWEsRUFBRTtZQUNoQyxVQUFVLEdBQUcsUUFBUSxHQUFHLENBQUMsQ0FBQztTQUMzQjthQUFNLElBQUksS0FBSyxHQUFHLGFBQWEsRUFBRTtZQUNoQyxTQUFTLEdBQUcsUUFBUSxHQUFHLENBQUMsQ0FBQztTQUMxQjtLQUNGO0lBRUQsT0FBTyxJQUFJLENBQUM7QUFDZCxDQUFDLENBQUMifQ==
|
|
File without changes
|
|
@@ -14,4 +14,4 @@ exports.factorial = function (x) {
|
|
|
14
14
|
exports.memoizedFactorial = memoize_1.memoize(function (n) {
|
|
15
15
|
return n > 1 ? n * exports.memoizedFactorial(n - 1) : n;
|
|
16
16
|
});
|
|
17
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFjdG9yaWFsLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2FwcC9hbGdvcml0aG1zL2ZhY3RvcmlhbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxxQ0FBb0M7QUFHcEM7O0dBRUc7QUFDVSxRQUFBLFNBQVMsR0FBRyxVQUFDLENBQVM7SUFDakMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsaUJBQVMsQ0FBQyxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztBQUMxQyxDQUFDLENBQUM7QUFFRjs7R0FFRztBQUNVLFFBQUEsaUJBQWlCLEdBQWdDLGlCQUFPLENBQ25FLFVBQUMsQ0FBUztJQUNSLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLHlCQUFpQixDQUFDLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO0FBQ2xELENBQUMsQ0FDRixDQUFDIn0=
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.memoizedFibonacci = exports.fibonacci = void 0;
|
|
4
|
+
var memoize_1 = require("./memoize");
|
|
5
|
+
/**
|
|
6
|
+
* Time complexity: O(n!)
|
|
7
|
+
*/
|
|
8
|
+
exports.fibonacci = function (n) {
|
|
9
|
+
return n > 1 ? exports.fibonacci(n - 1) + exports.fibonacci(n - 2) : n;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Time complexity: O(n) - due to caching
|
|
13
|
+
*/
|
|
14
|
+
exports.memoizedFibonacci = memoize_1.memoize(function (n) {
|
|
15
|
+
return n > 1 ? exports.memoizedFibonacci(n - 1) + exports.memoizedFibonacci(n - 2) : n;
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmlib25hY2NpLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2FwcC9hbGdvcml0aG1zL2ZpYm9uYWNjaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFDQSxxQ0FBb0M7QUFFcEM7O0dBRUc7QUFDVSxRQUFBLFNBQVMsR0FBRyxVQUFDLENBQVM7SUFDakMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxpQkFBUyxDQUFDLENBQUMsR0FBRyxDQUFDLENBQUMsR0FBRyxpQkFBUyxDQUFDLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO0FBQ3pELENBQUMsQ0FBQztBQUVGOztHQUVHO0FBQ1UsUUFBQSxpQkFBaUIsR0FBZ0MsaUJBQU8sQ0FDbkUsVUFBQyxDQUFTO0lBQ1IsT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQyx5QkFBaUIsQ0FBQyxDQUFDLEdBQUcsQ0FBQyxDQUFDLEdBQUcseUJBQWlCLENBQUMsQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7QUFDekUsQ0FBQyxDQUNGLENBQUMifQ==
|
package/lib/{data-structures/Graph → app/algorithms/graph}/iterator/AbstractGraphIterator.d.ts
RENAMED
|
File without changes
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
3
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
4
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
5
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
6
|
+
r[k] = a[j];
|
|
7
|
+
return r;
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
var IsNotFoundException_1 = require("../../../exceptions/IsNotFoundException");
|
|
11
|
+
var IllegalStateException_1 = require("../../../exceptions/base/IllegalStateException");
|
|
12
|
+
var AbstractGraphIterator = /** @class */ (function () {
|
|
13
|
+
/**
|
|
14
|
+
* Creates empty instance
|
|
15
|
+
*/
|
|
16
|
+
function AbstractGraphIterator(graph) {
|
|
17
|
+
this.graph = graph;
|
|
18
|
+
this.visited = new Map();
|
|
19
|
+
this.parents = new Map();
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
AbstractGraphIterator.prototype.initIterator = function (from) {
|
|
25
|
+
if (!this.graph.hasVertex(from)) {
|
|
26
|
+
throw new IsNotFoundException_1.default("Start vertex does not exist");
|
|
27
|
+
}
|
|
28
|
+
this.initIteratorImpl(from);
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* @inheritDoc
|
|
32
|
+
*/
|
|
33
|
+
AbstractGraphIterator.prototype.hasNext = function () {
|
|
34
|
+
return this.hasNextImpl();
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* @inheritDoc
|
|
38
|
+
*/
|
|
39
|
+
AbstractGraphIterator.prototype.next = function () {
|
|
40
|
+
if (!this.hasNext()) {
|
|
41
|
+
throw new IllegalStateException_1.default("Next element does not exist");
|
|
42
|
+
}
|
|
43
|
+
return this.nextImpl();
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* @inheritDoc
|
|
47
|
+
*/
|
|
48
|
+
AbstractGraphIterator.prototype.current = function () {
|
|
49
|
+
try {
|
|
50
|
+
return this.currentImpl();
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
throw new IllegalStateException_1.default("Current element does not exist");
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* @inheritDoc
|
|
58
|
+
*/
|
|
59
|
+
AbstractGraphIterator.prototype.getPath = function (from, to) {
|
|
60
|
+
var path = new Array();
|
|
61
|
+
var isLinkedDirectly = this.graph.hasEdge(from, to);
|
|
62
|
+
var currentVertex = this.parents.get(to);
|
|
63
|
+
if (isLinkedDirectly) {
|
|
64
|
+
return [from, to];
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
while (currentVertex) {
|
|
68
|
+
if (currentVertex === from) {
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
path.push(currentVertex);
|
|
72
|
+
currentVertex = this.parents.get(currentVertex);
|
|
73
|
+
}
|
|
74
|
+
if (path.length === 0) {
|
|
75
|
+
throw new IllegalStateException_1.default("There is no path found");
|
|
76
|
+
}
|
|
77
|
+
return __spreadArrays([from], path.reverse(), [to]);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
return AbstractGraphIterator;
|
|
81
|
+
}());
|
|
82
|
+
exports.default = AbstractGraphIterator;
|
|
83
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQWJzdHJhY3RHcmFwaEl0ZXJhdG9yLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vc3JjL2FwcC9hbGdvcml0aG1zL2dyYXBoL2l0ZXJhdG9yL0Fic3RyYWN0R3JhcGhJdGVyYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7QUFFQSwrRUFBMEU7QUFDMUUsd0ZBQW1GO0FBRW5GO0lBTUU7O09BRUc7SUFDSCwrQkFBc0IsS0FBZ0I7UUFDcEMsSUFBSSxDQUFDLEtBQUssR0FBRyxLQUFLLENBQUM7UUFDbkIsSUFBSSxDQUFDLE9BQU8sR0FBRyxJQUFJLEdBQUcsRUFBRSxDQUFDO1FBQ3pCLElBQUksQ0FBQyxPQUFPLEdBQUcsSUFBSSxHQUFHLEVBQUUsQ0FBQztJQUMzQixDQUFDO0lBT0Q7O09BRUc7SUFD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MsR0FBRyxDQUFDLEVBQUUsQ0FBQyxDQUFDO1FBRXpDLElBQUksZ0JBQWdCLEVBQUU7WUFDcEIsT0FBTyxDQUFDLElBQUksRUFBRSxFQUFFLENBQUMsQ0FBQztTQUNuQjthQUFNO1lBQ0wsT0FBTyxhQUFhLEVBQUU7Z0JBQ3BCLElBQUksYUFBYSxLQUFLLElBQUksRUFBRTtvQkFDMUIsTUFBTTtpQkFDUDtnQkFFRCxJQUFJLENBQUMsSUFBSSxDQUFDLGFBQWEsQ0FBQyxDQUFDO2dCQUN6QixhQUFhLEdBQUcsSUFBSSxDQUFDLE9BQU8sQ0FBQyxHQUFHLENBQUMsYUFBYSxDQUFDLENBQUM7YUFDakQ7WUFFRCxJQUFJLElBQUksQ0FBQyxNQUFNLEtBQUssQ0FBQyxFQUFFO2dCQUNyQixNQUFNLElBQUksK0JBQXFCLENBQUMsd0JBQXdCLENBQUMsQ0FBQzthQUMzRDtZQUVELHVCQUFRLElBQUksR0FBSyxJQUFJLENBQUMsT0FBTyxFQUFFLEdBQUUsRUFBRSxHQUFFO1NBQ3RDO0lBQ0gsQ0FBQztJQUNILDRCQUFDO0FBQUQsQ0FBQyxBQXRGRCxJQXNGQyJ9
|
|
File without changes
|
|
@@ -13,7 +13,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
13
13
|
};
|
|
14
14
|
})();
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
var Queue_1 = require("
|
|
16
|
+
var Queue_1 = require("../../../data-structures/Queue/Queue");
|
|
17
17
|
var AbstractGraphIterator_1 = require("./AbstractGraphIterator");
|
|
18
18
|
/**
|
|
19
19
|
* Breadth first graph traversal
|
|
@@ -67,4 +67,4 @@ var GraphIteratorBFS = /** @class */ (function (_super) {
|
|
|
67
67
|
return GraphIteratorBFS;
|
|
68
68
|
}(AbstractGraphIterator_1.default));
|
|
69
69
|
exports.default = GraphIteratorBFS;
|
|
70
|
-
//# sourceMappingURL=data:application/json;base64,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0FBQyxLQUFLLENBQUMsR0FBRyxFQUFFLENBQUM7UUFDOUIsSUFBTSxhQUFhLEdBQUcsSUFBSSxDQUFDLEtBQUssQ0FBQyxrQkFBa0IsQ0FBQyxJQUFJLENBQUMsQ0FBQztRQUUxRCxhQUFhLENBQUMsT0FBTyxDQUFDLFVBQUMsUUFBUTtZQUM3QixJQUFNLFlBQVksR0FBRyxDQUFDLEtBQUksQ0FBQyxPQUFPLENBQUMsR0FBRyxDQUFDLFFBQVEsQ0FBQyxDQUFDO1lBRWpELElBQUksWUFBWSxFQUFFO2dCQUNoQixLQUFJLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxRQUFRLENBQUMsQ0FBQztnQkFDMUIsS0FBSSxDQUFDLE9BQU8sQ0FBQyxHQUFHLENBQUMsUUFBUSxFQUFFLElBQUksQ0FBQyxDQUFDO2dCQUNqQyxLQUFJLENBQUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxRQUFRLEVBQUUsSUFBSSxDQUFDLENBQUM7YUFDbEM7UUFDSCxDQUFDLENBQUMsQ0FBQztRQUVILE9BQU8sSUFBSSxDQUFDO0lBQ2QsQ0FBQztJQUNILHVCQUFDO0FBQUQsQ0FBQyxBQXBERCxDQUFpRCwrQkFBcUIsR0FvRHJFIn0=
|
|
File without changes
|
|
@@ -13,7 +13,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
13
13
|
};
|
|
14
14
|
})();
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
var Stack_1 = require("
|
|
16
|
+
var Stack_1 = require("../../../data-structures/Stack/Stack");
|
|
17
17
|
var AbstractGraphIterator_1 = require("./AbstractGraphIterator");
|
|
18
18
|
/**
|
|
19
19
|
* Deep first graph traversal
|
|
@@ -67,4 +67,4 @@ var GraphIteratorDFS = /** @class */ (function (_super) {
|
|
|
67
67
|
return GraphIteratorDFS;
|
|
68
68
|
}(AbstractGraphIterator_1.default));
|
|
69
69
|
exports.default = GraphIteratorD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VDO1FBZEMsSUFBTSxJQUFJLEdBQUcsSUFBSSxDQUFDLEtBQUssQ0FBQyxHQUFHLEVBQUUsQ0FBQztRQUM5QixJQUFNLGFBQWEsR0FBRyxJQUFJLENBQUMsS0FBSyxDQUFDLGtCQUFrQixDQUFDLElBQUksQ0FBQyxDQUFDO1FBRTFELGFBQWEsQ0FBQyxPQUFPLENBQUMsVUFBQyxRQUFRO1lBQzdCLElBQU0sWUFBWSxHQUFHLENBQUMsS0FBSSxDQUFDLE9BQU8sQ0FBQyxHQUFHLENBQUMsUUFBUSxDQUFDLENBQUM7WUFFakQsSUFBSSxZQUFZLEVBQUU7Z0JBQ2hCLEtBQUksQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLFFBQVEsQ0FBQyxDQUFDO2dCQUMxQixLQUFJLENBQUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxRQUFRLEVBQUUsSUFBSSxDQUFDLENBQUM7Z0JBQ2pDLEtBQUksQ0FBQyxPQUFPLENBQUMsR0FBRyxDQUFDLFFBQVEsRUFBRSxJQUFJLENBQUMsQ0FBQzthQUNsQztRQUNILENBQUMsQ0FBQyxDQUFDO1FBRUgsT0FBTyxJQUFJLENBQUM7SUFDZCxDQUFDO0lBQ0gsdUJBQUM7QUFBRCxDQUFDLEFBcERELENBQWlELCtCQUFxQixHQW9EckUifQ==
|
package/lib/{data-structures/Graph → app/algorithms/graph}/iterator/GraphIteratorDijkstra.d.ts
RENAMED
|
File without changes
|
package/lib/{data-structures/Graph → app/algorithms/graph}/iterator/GraphIteratorDijkstra.js
RENAMED
|
@@ -14,6 +14,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
})();
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
var AbstractGraphIterator_1 = require("./AbstractGraphIterator");
|
|
17
|
+
var IllegalStateException_1 = require("../../../exceptions/base/IllegalStateException");
|
|
17
18
|
/**
|
|
18
19
|
* Dijkstra method graph traversal
|
|
19
20
|
*/
|
|
@@ -41,7 +42,7 @@ var GraphIteratorDijkstra = /** @class */ (function (_super) {
|
|
|
41
42
|
return aCost - bCost;
|
|
42
43
|
});
|
|
43
44
|
if (priorityList[0] === undefined) {
|
|
44
|
-
throw new
|
|
45
|
+
throw new IllegalStateException_1.default("No more vertices found");
|
|
45
46
|
}
|
|
46
47
|
return priorityList[0];
|
|
47
48
|
};
|
|
@@ -50,9 +51,6 @@ var GraphIteratorDijkstra = /** @class */ (function (_super) {
|
|
|
50
51
|
*/
|
|
51
52
|
GraphIteratorDijkstra.prototype.initIteratorImpl = function (startVertex) {
|
|
52
53
|
var _this = this;
|
|
53
|
-
if (!this.graph.hasVertex(startVertex)) {
|
|
54
|
-
throw new Error("Start vertex does not exist");
|
|
55
|
-
}
|
|
56
54
|
this.visited.set(startVertex, true);
|
|
57
55
|
this.costs.set(startVertex, 0);
|
|
58
56
|
this.graph.getVertexNeighbors(startVertex).forEach(function (neighbor) {
|
|
@@ -96,4 +94,4 @@ var GraphIteratorDijkstra = /** @class */ (function (_super) {
|
|
|
96
94
|
return GraphIteratorDijkstra;
|
|
97
95
|
}(AbstractGraphIterator_1.default));
|
|
98
96
|
exports.default = GraphIteratorDijkstra;
|
|
99
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
97
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiR3JhcGhJdGVyYXRvckRpamtzdHJhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vc3JjL2FwcC9hbGdvcml0aG1zL2dyYXBoL2l0ZXJhdG9yL0dyYXBoSXRlcmF0b3JEaWprc3RyYS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7QUFDQSxpRUFBNEQ7QUFDNUQsd0ZBQW1GO0FBRW5GOztHQUVHO0FBQ0g7SUFBc0QseUNBQXdCO0lBRzVFOztPQU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SyxDQUFDLGtCQUFrQixDQUFDLElBQUksQ0FBQyxDQUFDO1FBQzFELElBQU0sUUFBUSxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUMsR0FBRyxDQUFDLElBQUksQ0FBQyxDQUFDO1FBRXRDLGFBQWEsQ0FBQyxPQUFPLENBQUMsVUFBQyxRQUFXO1lBQ2hDLElBQU0sVUFBVSxHQUFHLEtBQUksQ0FBQyxLQUFLLENBQUMsYUFBYSxDQUFDLElBQUksRUFBRSxRQUFRLENBQUMsQ0FBQztZQUM1RCxJQUFNLG1CQUFtQixHQUFHLEtBQUksQ0FBQyxLQUFLLENBQUMsR0FBRyxDQUFDLFFBQVEsQ0FBQyxJQUFJLFFBQVEsQ0FBQztZQUNqRSxJQUFNLGVBQWUsR0FBRyxDQUFDLFFBQVEsSUFBSSxDQUFDLENBQUMsR0FBRyxVQUFVLENBQUM7WUFFckQsSUFBSSxlQUFlLEdBQUcsbUJBQW1CLEVBQUU7Z0JBQ3pDLEtBQUksQ0FBQyxLQUFLLENBQUMsR0FBRyxDQUFDLFFBQVEsRUFBRSxlQUFlLENBQUMsQ0FBQztnQkFDMUMsS0FBSSxDQUFDLE9BQU8sQ0FBQyxHQUFHLENBQUMsUUFBUSxFQUFFLElBQUksQ0FBQyxDQUFDO2FBQ2xDO1FBQ0gsQ0FBQyxDQUFDLENBQUM7UUFFSCxPQUFPLElBQUksQ0FBQztJQUNkLENBQUM7SUFDSCw0QkFBQztBQUFELENBQUMsQUFuRkQsQ0FBc0QsK0JBQXFCLEdBbUYxRSJ9
|
|
File without changes
|
|
@@ -10,4 +10,4 @@ var BFSIterationStrategy = /** @class */ (function () {
|
|
|
10
10
|
return BFSIterationStrategy;
|
|
11
11
|
}());
|
|
12
12
|
exports.default = BFSIterationStrategy;
|
|
13
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
13
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQkZTSXRlcmF0aW9uU3RyYXRlZ3kuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9zcmMvYXBwL2FsZ29yaXRobXMvZ3JhcGgvaXRlcmF0b3Itc3RyYXRlZ3kvQkZTSXRlcmF0aW9uU3RyYXRlZ3kudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFHQSxpRUFBNEQ7QUFFNUQ7SUFBQTtJQUtBLENBQUM7SUFIUSw2Q0FBYyxHQUFyQixVQUFzQixLQUFnQjtRQUNwQyxPQUFPLElBQUksMEJBQWdCLENBQUksS0FBSyxDQUFDLENBQUM7SUFDeEMsQ0FBQztJQUNILDJCQUFDO0FBQUQsQ0FBQyxBQUxELElBS0MifQ==
|
|
File without changes
|
|
@@ -10,4 +10,4 @@ var DFSIterationStrategy = /** @class */ (function () {
|
|
|
10
10
|
return DFSIterationStrategy;
|
|
11
11
|
}());
|
|
12
12
|
exports.default = DFSIterationStrategy;
|
|
13
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
13
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiREZTSXRlcmF0aW9uU3RyYXRlZ3kuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9zcmMvYXBwL2FsZ29yaXRobXMvZ3JhcGgvaXRlcmF0b3Itc3RyYXRlZ3kvREZTSXRlcmF0aW9uU3RyYXRlZ3kudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFHQSxpRUFBNEQ7QUFFNUQ7SUFBQTtJQUtBLENBQUM7SUFIUSw2Q0FBYyxHQUFyQixVQUFzQixLQUFnQjtRQUNwQyxPQUFPLElBQUksMEJBQWdCLENBQUMsS0FBSyxDQUFDLENBQUM7SUFDckMsQ0FBQztJQUNILDJCQUFDO0FBQUQsQ0FBQyxBQUxELElBS0MifQ==
|
|
File without changes
|
|
@@ -10,4 +10,4 @@ var DijkstraIterationStrategy = /** @class */ (function () {
|
|
|
10
10
|
return DijkstraIterationStrategy;
|
|
11
11
|
}());
|
|
12
12
|
exports.default = DijkstraIterationStrategy;
|
|
13
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
13
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRGlqa3N0cmFJdGVyYXRpb25TdHJhdGVneS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3NyYy9hcHAvYWxnb3JpdGhtcy9ncmFwaC9pdGVyYXRvci1zdHJhdGVneS9EaWprc3RyYUl0ZXJhdGlvblN0cmF0ZWd5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBR0EsMkVBQXNFO0FBRXRFO0lBQUE7SUFLQSxDQUFDO0lBSFEsa0RBQWMsR0FBckIsVUFBc0IsS0FBZ0I7UUFDcEMsT0FBTyxJQUFJLCtCQUFxQixDQUFDLEtBQUssQ0FBQyxDQUFDO0lBQzFDLENBQUM7SUFDSCxnQ0FBQztBQUFELENBQUMsQUFMRCxJQUtDIn0=
|
package/lib/{data-structures/Graph → app/algorithms/graph}/presenter/presenterAdjacencyLists.d.ts
RENAMED
|
File without changes
|
package/lib/{data-structures/Graph → app/algorithms/graph}/presenter/presenterAdjacencyLists.js
RENAMED
|
@@ -25,4 +25,4 @@ exports.presenterAdjacencyLists = function (graph) {
|
|
|
25
25
|
return map;
|
|
26
26
|
}, new Map());
|
|
27
27
|
};
|
|
28
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
28
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJlc2VudGVyQWRqYWNlbmN5TGlzdHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9zcmMvYXBwL2FsZ29yaXRobXMvZ3JhcGgvcHJlc2VudGVyL3ByZXNlbnRlckFkamFjZW5jeUxpc3RzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUVBOzs7Ozs7Ozs7Ozs7Ozs7O0lBZ0JJO0FBQ1MsUUFBQSx1QkFBdUIsR0FBRyxVQUNyQyxLQUFnQjtJQUVoQixPQUFPLEtBQUssQ0FBQyxRQUFRLEVBQUUsQ0FBQyxNQUFNLENBQUMsVUFBQyxHQUFxQixFQUFFLE1BQVM7UUFDOUQsSUFBTSxTQUFTLEdBQUcsS0FBSyxDQUFDLGtCQUFrQixDQUFDLE1BQU0sQ0FBQyxDQUFDO1FBQ25ELEdBQUcsQ0FBQyxHQUFHLENBQUMsTUFBTSxFQUFFLFNBQVMsQ0FBQyxDQUFDO1FBRTNCLE9BQU8sR0FBRyxDQUFDO0lBQ2IsQ0FBQyxFQUFFLElBQUksR0FBRyxFQUFFLENBQUMsQ0FBQztBQUNoQixDQUFDLENBQUMifQ==
|
package/lib/{data-structures/Graph → app/algorithms/graph}/presenter/presenterAdjacencyMatrix.d.ts
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import IGraph from "../../../types/IGraph";
|
|
2
|
-
import {
|
|
2
|
+
import { TypeArrayMatrix } from "../../../types/TypeArrayMatrix";
|
|
3
3
|
/**
|
|
4
4
|
* Get graph adjacency matrix N x N
|
|
5
5
|
*
|
|
@@ -29,4 +29,4 @@ import { ArrayMatrix } from "../../../types/ArrayMatrix";
|
|
|
29
29
|
* Maria | 1 | 0 | 1 |
|
|
30
30
|
* John | 0 | 1 | 0 |
|
|
31
31
|
*/
|
|
32
|
-
export declare const presenterAdjacencyMatrix: <T>(graph: IGraph<T>) =>
|
|
32
|
+
export declare const presenterAdjacencyMatrix: <T>(graph: IGraph<T>) => TypeArrayMatrix;
|
package/lib/{data-structures/Graph → app/algorithms/graph}/presenter/presenterAdjacencyMatrix.js
RENAMED
|
@@ -45,4 +45,4 @@ exports.presenterAdjacencyMatrix = function (graph) {
|
|
|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