0
0
DSA Goprogramming~10 mins

Shell Sort Algorithm in DSA Go - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to initialize the gap for Shell Sort.

DSA Go
gap := len(arr) [1] 2
Drag options to blanks, or click blank then click option'
A+
B*
C/
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition or multiplication instead of division for gap initialization.
2fill in blank
medium

Complete the code to reduce the gap in each iteration of Shell Sort.

DSA Go
gap = gap [1] 2
Drag options to blanks, or click blank then click option'
A-
B/
C+
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction or multiplication instead of division to reduce the gap.
3fill in blank
hard

Fix the error in the inner loop condition to correctly compare elements during Shell Sort.

DSA Go
for j := i; j >= gap && arr[j-gap] [1] arr[j]; j -= gap {
Drag options to blanks, or click blank then click option'
A>
B<
C==
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using less than or equal instead of greater than in the comparison.
4fill in blank
hard

Fill both blanks to correctly insert the element in its sorted position during Shell Sort.

DSA Go
temp := arr[i]
for j := i; j >= [1] && arr[j-[2]] > temp; j -= [2] {
    arr[j] = arr[j-[2]]
}
Drag options to blanks, or click blank then click option'
Agap
Bi
Ctemp
Dj
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong variable like i or temp instead of gap.
5fill in blank
hard

Fill all three blanks to complete the Shell Sort insertion step correctly.

DSA Go
arr[j] = [1]
}

for gap > 0 {
    for i := gap; i < len(arr); i++ {
        temp := arr[i]
        j := i
        for j >= gap && arr[j-gap] > temp {
            arr[j] = arr[j-gap]
            j -= [2]
        }
        arr[j] = [3]
    }
    gap /= 2
Drag options to blanks, or click blank then click option'
Atemp
Bgap
Di
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong variables for decrement or insertion.