Skip to content

feat: add DFS, Rabin-Karp, and math algorithms#74

Merged
monkey0722 merged 7 commits into
mainfrom
feat/20260415
Apr 15, 2026
Merged

feat: add DFS, Rabin-Karp, and math algorithms#74
monkey0722 merged 7 commits into
mainfrom
feat/20260415

Conversation

@monkey0722
Copy link
Copy Markdown
Owner

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:

  • Added iterative and recursive DFS functions (dfs, dfsRecursive) with input validation, predecessor tracking, and clear documentation in src/algorithms/graph/dfs/dfs.ts. Also included a reconstructPath utility to build a path from source to target using DFS results.

Testing:

  • Created a comprehensive test suite in src/algorithms/graph/dfs/dfs.test.ts covering various graph structures, error handling, performance on large graphs, and correctness of path reconstruction.

Tooling:

  • Added a new check:all script to package.json to run tests, linting, and type checking in one command for improved developer workflow.

- 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
@monkey0722 monkey0722 self-assigned this Apr 15, 2026
@monkey0722 monkey0722 merged commit 00418bc into main Apr 15, 2026
1 check passed
@monkey0722 monkey0722 deleted the feat/20260415 branch April 15, 2026 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant