Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using multiplication instead of division.
Using addition or subtraction which does not find the middle.
✗ Incorrect
To find the middle index, divide the length of the array by 2 using '/'.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using full length instead of mid.
Using 0 or 1 which does not slice correctly.
✗ Incorrect
The left half is from start to mid index, so use 'mid' as the slice end.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' which reverses sorting order.
Using '==' which only checks equality.
✗ Incorrect
We compare if left[i] is less than right[j] to merge in sorted order.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '++' alone which is invalid in Go.
Using wrong index variable or missing brackets.
✗ Incorrect
Use '[i]' to access element and 'i++' to move index forward.
5fill in blank
hardFill 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'
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.
✗ Incorrect
Use '<' to check bounds, '<' to compare elements, and '++' to increment index.