Multiple choice

In a shell sort, the second gap is _______ .

  1. 1/2 the length of the array

  2. 1/2 of the first gap

  3. 1/2 of the third gap

  4. 1/2 of itself

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Shell sort uses a sequence of diminishing gaps to compare and sort elements. A common gap sequence starts with N/2, then N/4, N/8, and so on. Each successive gap is typically half the previous one, eventually reaching gap=1 which is equivalent to a final bubble sort pass.