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

Shell Sort Algorithm -- Java #574

Open
AfaqShuaib09 opened this issue Oct 23, 2024 · 1 comment
Open

Shell Sort Algorithm -- Java #574

AfaqShuaib09 opened this issue Oct 23, 2024 · 1 comment

Comments

@AfaqShuaib09
Copy link

Shell Sort Algorithm

Description:

Shell Sort is an optimization of Insertion Sort, where elements are sorted over increasing intervals (called gaps) rather than adjacent positions. This allows the exchange of elements that are far apart, which can lead to faster convergence on a sorted array compared to regular Insertion Sort. As the algorithm progresses, the gap is reduced, eventually performing a final pass using a gap of 1, effectively running a standard Insertion Sort.

Task:

Implement the Shell Sort algorithm in [language] to sort an array of integers. The solution should:

  • Accept an array of integers as input.
  • Sort the array in ascending order using Shell Sort.
  • Return the sorted array.

Key Details:

The gap sequence can be calculated by starting with n/2 (where n is the array length) and halving the gap until it reaches 1.
Ensure the algorithm works efficiently with both small and large input arrays.

Resources:

Example:

Input:

[12, 34, 54, 2, 3]

Output:

[2, 3, 12, 34, 54]

Additional Notes:

  • Include test cases to verify correctness.
  • Ensure that the code adheres to project style guidelines and is well-documented.
@AfaqShuaib09
Copy link
Author

Hey @Ayush7-BIT Please assign me this issue. I'll be creating the PR against this issue Thanks

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

No branches or pull requests

1 participant