DSA Lab

Shell sort visualizer

Insertion sort on items far apart first (gap n/2, then n/4, ... down to 1). Big jumps early mean the final gap-1 pass has little left to do. Mid-sized lists on small devices: fast, no extra memory, and short code.

Shell sort: its cost, and how to use this tool

Time: best O(n log n), average about O(n^1.25), worst O(n²) with these gaps. Extra memory: O(1). Not stable, in place.

Sort a ready-made input or your own numbers. The bars are the array; the code beside them (in Python, C, C++ or Java) marks the line that just ran, and every step is explained and worked out below the bars.

See also