Skip to content

Conversation

@codomposer
Copy link
Contributor

@codomposer codomposer commented Nov 4, 2025

Description

This PR adds two new implementations to the repository:

  1. Kadane's Algorithm - A dynamic programming algorithm for finding the maximum sum of a contiguous subarray
  2. Deque (Double-Ended Queue) - A data structure that allows insertion and deletion from both ends

Changes

Algorithm: Kadane's Algorithm

  • File: Algorithms/Other/KadanesAlgorithm.cs
  • Implements maximum subarray sum with O(n) time complexity
  • Supports both int and long data types
  • Includes variant that returns subarray indices
  • Reference: "Introduction to Algorithms" by CLRS

Data Structure: Deque

  • File: DataStructures/Deque/Deque.cs
  • Circular array implementation with O(1) operations
  • Automatic capacity doubling when full
  • Supports AddFront, AddRear, RemoveFront, RemoveRear operations
  • Reference: "Data Structures and Algorithms in C#" by Goodrich

Tests

  • 17 comprehensive tests for Kadane's Algorithm covering edge cases, mixed numbers, and long integers
  • 22 comprehensive tests for Deque covering circular behavior, resizing, and type flexibility

Documentation

  • Detailed XML documentation with examples
  • Inline comments explaining algorithm logic
  • Time/space complexity analysis
  • Real-world use case descriptions

Closes #549
Closes #465

Checklist

  • I have performed a self-review of my code
  • My code follows the style guidelines of this project
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Comments in areas I changed are up to date
  • I have added comments to hard-to-understand areas of my code
  • I have made corresponding changes to the README.md

Testing

All tests pass successfully:

  • KadanesAlgorithmTests: 17/17 tests passing
  • DequeTests: 22/22 tests passing

Additional Notes

Both implementations target .NET 8 and follow the repository's coding standards with comprehensive documentation for educational purposes.

@codomposer codomposer requested a review from siriak as a code owner November 4, 2025 15:47
@siriak
Copy link
Member

siriak commented Nov 4, 2025

Please check the PR check failing

@codomposer
Copy link
Contributor Author

@siriak I've already fixed the failing issue

@codecov
Copy link

codecov bot commented Nov 4, 2025

Codecov Report

❌ Patch coverage is 97.50000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.81%. Comparing base (8ec0781) to head (9ae60e8).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
DataStructures/Deque/Deque.cs 96.22% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@ ## master #552 +/- ## ======================================== Coverage 96.81% 96.81% ======================================== Files 284 286 +2 Lines 11593 11753 +160 Branches 1668 1687 +19 ======================================== + Hits 11224 11379 +155  - Misses 234 237 +3  - Partials 135 137 +2 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@siriak siriak merged commit cf79871 into TheAlgorithms:master Nov 4, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants