Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using multiplication instead of division.
Using addition or subtraction instead of division.
✗ Incorrect
We use division by 2 to find the middle point between start and end.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using end instead of mid for the left half.
Using mid + 1 which belongs to the right half.
✗ Incorrect
We pass mid as the end index for the left half.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using equality instead of greater than.
Using less than which causes infinite recursion.
✗ Incorrect
The recursion stops when start is greater than end, meaning no elements to process.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using start or end incorrectly for halves.
Mixing up mid and mid + 1.
✗ Incorrect
The left half ends at mid, the right half starts at mid + 1.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Starting j at mid instead of mid + 1.
Using wrong end points for i or j.
✗ Incorrect
We start j at mid + 1, i goes up to mid, and j goes up to end to merge halves.