feat: add DFS, Rabin-Karp, and math algorithms#74
Merged
Conversation
- Implement Euler's Totient Function in `eulerTotient.ts` - Add Extended Euclidean Algorithm and modular inverse in `extendedGcd.ts` - Create tests for Extended GCD and modular inverse in `extendedGcd.test.ts` - Implement factorial function in `factorial.ts` with corresponding tests - Add Fibonacci number calculation using matrix exponentiation in `fibMatrix.ts` with tests - Implement GCD function in `gcd.ts` and tests for various cases - Create Matrix class with operations (addition, multiplication, determinant, inverse) in `matrix.ts` and tests - Implement modular exponentiation function in `modPow.ts` with tests - Add prime factorization function in `primeFactors.ts` with tests - Implement Sieve of Eratosthenes for prime number generation in `sieveOfEratosthenes.ts` with tests - Update `tsconfig.json` to include all source files
…sive implementation
…aracters and prevent integer overflow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds a comprehensive implementation of the depth-first search (DFS) algorithm for graphs, including both iterative and recursive versions, as well as a utility for reconstructing paths. It also introduces thorough unit tests for these algorithms and adds a new convenience script to the project configuration for running all checks.
DFS Algorithm Implementation:
dfs,dfsRecursive) with input validation, predecessor tracking, and clear documentation insrc/algorithms/graph/dfs/dfs.ts. Also included areconstructPathutility to build a path from source to target using DFS results.Testing:
src/algorithms/graph/dfs/dfs.test.tscovering various graph structures, error handling, performance on large graphs, and correctness of path reconstruction.Tooling:
check:allscript topackage.jsonto run tests, linting, and type checking in one command for improved developer workflow.