Mental Model
Shell sort improves simple sorting by comparing elements far apart first, then gradually reducing the gap to sort closer elements.
Analogy: Imagine organizing books on a shelf by first sorting every 5th book, then every 3rd, and finally every book next to each other to get a fully sorted shelf.
Array: [8, 5, 3, 7, 6, 2, 4, 1] Gap = 4 Indexes: 0 -> 4 -> null Values: 8 -> 6 -> null
