# What is the formula to get the number of passes in a shell sort?

0

I'm referring to the original (Donald Shell's) algorithm. I'm trying to make a subjective sort based on shell sort. I already made all the logic, where it is exactly the same as the shell sort, but instead of the computer calculate what is greater, the user determines subjectively what is greater. But I would like to display a percentage or something to the user know how far in the sorting it is already. That's why I want to find a way to know it.

What is the formula to get the number of passes in a shell sort? I noticed it the number is not fixed, so what would be the minimum and maximum? N and N^2? Or maybe if you have an idea of how it is the best way to display the progress of the sorting, I will really appreciate it.

PS: It is not about the number of comparisons! Also not about time complexity. My question is about the number of passes in the array.

I did this formula displaying it by color. But it doesn't work with the right range.

``````List<Color> colors = [
Color(0xFFFF0000),//red
Color(0xFFFF5500),
Color(0xFFFFAA00),
Color(0xFFFFFF00),//yellow
Color(0xFFAAFF00),
Color(0xFF00FF00),
Color(0xFF00FF00),//green
];
[...]
style: TextStyle(
color: colors[(((pass - 1) * (colors.length - 1)) /
sqrt(a.length).ceil())
.floor()]),
[...]
``````
sorting
math
dart
shellsort