Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to initialize the low pointer to the start of the array.
DSA C#
int low = [1];Attempts:
3 left
💡 Hint
Common Mistakes
Starting low at 1 skips the first element.
Using -1 causes index errors.
Setting low to array.Length is out of bounds.
✗ Incorrect
The low pointer should start at index 0 to begin partitioning from the start.
2fill in blank
mediumComplete the code to swap elements at indices i and low.
DSA C#
int temp = arr[i]; arr[i] = arr[[1]]; arr[low] = temp;Attempts:
3 left
💡 Hint
Common Mistakes
Swapping with high moves wrong elements.
Swapping with i does nothing.
Swapping with pivot is incorrect here.
✗ Incorrect
We swap arr[i] with arr[low] to move the smaller element to the front.
3fill in blank
hardFix the error in the loop condition to iterate through the array correctly.
DSA C#
while (i [1] high) { /* partition logic */ }
Attempts:
3 left
💡 Hint
Common Mistakes
Using < misses the last element.
Using > or >= causes infinite loops or no iteration.
✗ Incorrect
The loop should run while i is less than or equal to high to cover all elements.
4fill in blank
hardFill both blanks to correctly update pointers after swapping with high.
DSA C#
int temp = arr[i]; arr[i] = arr[[1]]; arr[[2]] = temp; high--;
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping with low instead of high.
Assigning temp to wrong index causes data loss.
✗ Incorrect
Swap arr[i] with arr[high] and assign temp to arr[i], then decrement high.
5fill in blank
hardFill all three blanks to complete the partition loop with correct pointer updates.
DSA C#
while (i [1] high) { if (arr[i] < pivot) { Swap(arr, i, [2]); [3]++; i++; } else if (arr[i] > pivot) { Swap(arr, i, high); high--; } else { i++; } }
Attempts:
3 left
💡 Hint
Common Mistakes
Using < excludes last element.
Incrementing wrong pointers causes infinite loops.
✗ Incorrect
Loop while i <= high; swap with low pointer; increment low and i after swap.
