Skip to content

fix: correct insertion sort loop structure#5

Open
trett1004 wants to merge 1 commit intoMr-G-D:masterfrom
trett1004:fix/insertion-sort
Open

fix: correct insertion sort loop structure#5
trett1004 wants to merge 1 commit intoMr-G-D:masterfrom
trett1004:fix/insertion-sort

Conversation

@trett1004
Copy link
Contributor

Summary

This PR fixes the insertion sort implementation by removing a redundant outer loop that repeated the full insertion process unnecessarily.

Problem

The previous implementation wrapped the normal insertion pass inside an unnecessary extra full loop.
That caused repeated work without improving correctness.

Complexity Impact

  • Expected insertion sort complexity: O(n²) (average/worst case)
  • Previous implementation complexity: effectively O(n³) due to the extra outer loop
  • Updated implementation restores expected O(n²) behavior

What changed

  • Removed the unnecessary outer loop in insertion sort
  • Kept the existing visualization behavior and state updates intact

Related Issue

N/A

UI Changes

N/A (no UI layout changes)

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