0
0
DSA Goprogramming~10 mins

Merge 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 split the array into two halves.

DSA Go
mid := 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 multiplication instead of division.
Using addition or subtraction which does not find the middle.
2fill in blank
medium

Complete the code to recursively sort the left half of the array.

DSA Go
left := mergeSort(arr[:[1]])
Drag options to blanks, or click blank then click option'
Amid
Blen(arr)
C0
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using full length instead of mid.
Using 0 or 1 which does not slice correctly.
3fill in blank
hard

Fix the error in the merge function to compare elements correctly.

DSA Go
if left[i] [1] right[j] {
Drag options to blanks, or click blank then click option'
A<=
B>
C<
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' which reverses sorting order.
Using '==' which only checks equality.
4fill in blank
hard

Fill both blanks to append remaining elements after merging.

DSA Go
for i < len(left) {
    result = append(result, left[1])
    i[2]
}
Drag options to blanks, or click blank then click option'
A[i]
B++
Ci++
D[j]
Attempts:
3 left
💡 Hint
Common Mistakes
Using '++' alone which is invalid in Go.
Using wrong index variable or missing brackets.
5fill in blank
hard

Fill all three blanks to complete the merge function's main loop.

DSA Go
for i < len(left) && j [1] len(right) {
    if left[i] [2] right[j] {
        result = append(result, left[i])
        i[3]
    } else {
        result = append(result, right[j])
        j++
    }
}
Drag options to blanks, or click blank then click option'
A<
B<=
D++
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<=' in loop condition causing index out of range.
Using wrong comparison operator in if condition.
Missing index increment causing infinite loop.