0
0
DSA Cprogramming~10 mins

Merge Sort as Divide and Conquer in DSA C - Interactive Practice

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

Complete the code to find the middle index for dividing the array.

DSA C
int mid = (left [1] right) / 2;
Drag options to blanks, or click blank then click option'
A*
B-
C+
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction instead of addition
Dividing before adding
2fill in blank
medium

Complete the recursive call to sort the left half of the array.

DSA C
mergeSort(arr, [1], mid);
Drag options to blanks, or click blank then click option'
Aleft
B0
Cright
Dmid
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 instead of left
Using right instead of left
3fill in blank
hard

Fix the error in the merge function call to merge two halves correctly.

DSA C
merge(arr, left, [1], right);
Drag options to blanks, or click blank then click option'
Aright - 1
Bmid - 1
Cleft + 1
Dmid + 1
Attempts:
3 left
💡 Hint
Common Mistakes
Using mid - 1 instead of mid + 1
Using left + 1 incorrectly
4fill in blank
hard

Fill both blanks to complete the loop copying elements back to the original array.

DSA C
for (int k = [1]; k <= [2]; k++) {
    arr[k] = temp[k];
}
Drag options to blanks, or click blank then click option'
Aleft
Bmid
Cright
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Starting from 0 instead of left
Ending at mid instead of right
5fill in blank
hard

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

DSA C
while (i <= [1] && j <= [2]) {
    if (arr[i] <= arr[j]) {
        temp[k++] = arr[[3]++];
    } else {
        temp[k++] = arr[j++];
    }
}
Drag options to blanks, or click blank then click option'
Amid
Bright
Ci
Dleft
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong boundary values
Incrementing wrong index