Skip to content

Conversation

@codeahl
Copy link
Contributor

@codeahl codeahl commented Dec 10, 2025

This PR adds time and space complexity documentation to several sorting algorithm implementations in the repository. The following changes were made:

BubbleSort – Added best, average, and worst-case time complexity (O(n²)) and space complexity (O(1)) comments.
MergeSort – Added time complexity (O(n log n)) and space complexity (O(n)) comments.
QuickSort – Added best, average (O(n log n)), and worst-case (O(n²)) time complexity and space complexity (O(log n) recursive stack) comments.
SelectionSort – Added time complexity (O(n²)) and space complexity (O(1)) comments.
InsertionSort – Added time complexity (best: O(n), worst: O(n²)) and space complexity (O(1)) comments.
HeapSort – Added time complexity (O(n log n)) and space complexity (O(1)) comments.
TopologicalSort – Added comments describing the DFS approach, linear ordering of DAGs, and complexity (time: Θ(V + E), space: O(V + E)).

More comments will be needed however, to make time/space complexity clearer for the other algorithms.

Fixes #7123

@codecov-commenter
Copy link

codecov-commenter commented Dec 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.61%. Comparing base (e7c3e1f) to head (6dee3dc).

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #7155   +/-   ##
=========================================
  Coverage     78.61%   78.61%           
  Complexity     6824     6824           
=========================================
  Files           766      766           
  Lines         22607    22607           
  Branches       4444     4444           
=========================================
  Hits          17773    17773           
  Misses         4119     4119           
  Partials        715      715           

☔ 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

@DenizAltunkapan DenizAltunkapan left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution @codeahl

@DenizAltunkapan DenizAltunkapan merged commit 520151a into TheAlgorithms:master Dec 10, 2025
7 checks passed
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.

3 participants