Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

first commit #368

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

first commit #368

wants to merge 1 commit into from

Conversation

anuj2331
Copy link

@anuj2331 anuj2331 commented Oct 3, 2024

Memory Allocation:

Changed from calloc(n, sizeof(n)) to calloc(n, sizeof(int)) for correct integer allocation.
Early Exit in Bubble Sort:

Introduced a swapped flag to terminate the loop early if no swaps occur, enhancing performance.
Output Formatting:

Updated the printArray function to use commas instead of hyphens for clearer output.
Memory Allocation Check:

Added a check for successful memory allocation to avoid segmentation faults.
Memory Deallocation:

Included free(a); to release allocated memory and prevent memory leaks.
These changes improve correctness, efficiency, readability, and memory management.

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