0
0
DSA Cprogramming~10 mins

Why Divide and Conquer and What It Gives You in DSA C - Test Your Knowledge

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

Complete the code to divide the problem into two halves.

DSA C
int mid = (start + end) [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 instead of division.
2fill in blank
medium

Complete the code to recursively solve the left half of the problem.

DSA C
divideAndConquer(array, start, [1]);
Drag options to blanks, or click blank then click option'
Amid
Bend
Cstart
Dmid + 1
Attempts:
3 left
💡 Hint
Common Mistakes
Using end instead of mid for the left half.
Using mid + 1 which belongs to the right half.
3fill in blank
hard

Fix the error in the base case condition to stop recursion.

DSA C
if (start [1] end) return;
Drag options to blanks, or click blank then click option'
A==
B<
C>
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using equality instead of greater than.
Using less than which causes infinite recursion.
4fill in blank
hard

Fill both blanks to recursively solve left and right halves.

DSA C
divideAndConquer(array, start, [1]);
divideAndConquer(array, [2], end);
Drag options to blanks, or click blank then click option'
Amid
Bstart
Cmid + 1
Dend
Attempts:
3 left
💡 Hint
Common Mistakes
Using start or end incorrectly for halves.
Mixing up mid and mid + 1.
5fill in blank
hard

Fill all three blanks to merge two sorted halves correctly.

DSA C
int i = start, j = [1], k = 0;
while (i <= [2] && j <= [3]) {
    if (array[i] < array[j]) {
        temp[k++] = array[i++];
    } else {
        temp[k++] = array[j++];
    }
}
Drag options to blanks, or click blank then click option'
Amid + 1
Bmid
Cend
Dstart
Attempts:
3 left
💡 Hint
Common Mistakes
Starting j at mid instead of mid + 1.
Using wrong end points for i or j.