You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's an optimized version of your program. Improvements.
- Reduce repeated computation of `len(arr)` in loops.
- Make the bubble sort algorithm more efficient by stopping when no swaps occur (early exit).
- Remove unnecessary variable assignments (`temp`).
This is still bubble sort (for correctness), but with early-termination and less memory/operations. The function signatures, return values, and comments are preserved as requested.
0 commit comments