Skip to content

Recursive Insertion Sort Algo added#7372

Open
Shantanu675 wants to merge 5 commits intoTheAlgorithms:masterfrom
Shantanu675:update-1
Open

Recursive Insertion Sort Algo added#7372
Shantanu675 wants to merge 5 commits intoTheAlgorithms:masterfrom
Shantanu675:update-1

Conversation

@Shantanu675
Copy link
Copy Markdown

Recursive Insertion Sort algorithm.

This is a recursive implementation of the standard Insertion Sort algorithm.
Instead of iterating through the array, it sorts the first n-1 elements recursively
and then inserts the nth element into its correct position.

Concept:

  • Divide the problem into smaller subproblems by sorting first n-1 elements.
  • Insert the last element into the sorted portion.

Time Complexity:

  • Best case: O(n) – array is already sorted
  • Average case: O(n^2)
  • Worst case: O(n^2) – array is reverse sorted

Space Complexity:

  • O(n) – due to recursion stack

Note:

  • This implementation is mainly useful for understanding recursion.
  • Iterative insertion sort is preferred in production due to lower space overhead.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 11, 2026

Codecov Report

❌ Patch coverage is 94.11765% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 79.52%. Comparing base (1edf319) to head (3d83beb).

Files with missing lines Patch % Lines
...om/thealgorithms/sorts/RecursiveInsertionSort.java 94.11% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #7372      +/-   ##
============================================
+ Coverage     79.50%   79.52%   +0.02%     
- Complexity     7142     7153      +11     
============================================
  Files           796      797       +1     
  Lines         23368    23385      +17     
  Branches       4596     4597       +1     
============================================
+ Hits          18578    18597      +19     
  Misses         4050     4050              
+ Partials        740      738       -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.

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.

2 participants