Рет қаралды 41
Shellsort, also known as Shell sort or Shell's method, is an in-place comparison sort based algorithm. It can be seen as either a generalization of sorting by exchange or sorting by insertion. The method/algorithm works by sorting pairs of elements far apart from each other from a certain distance/gap, then progressively reducing the gap between elements to be compared.
After every Iteration we reduce the gap by n/2 and then compare the elements till we reach gap greater than 0.
And then at last we get the Sorted List of the Elements.
Shellsort Complexity -
Worst Case - Time Complexity - O(N^2)
Space Complexity - O(1)
#shellsort #dsalgo #datastructures #algorithm #java