Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to initialize the low pointer to zero.
DSA Rust
let mut low = [1];Attempts:
3 left
💡 Hint
Common Mistakes
Initializing low to 1 or -1 causes index errors.
Using None is invalid for integer index.
✗ Incorrect
The low pointer starts at index 0 to begin partitioning from the start of the array.
2fill in blank
mediumComplete the code to swap elements at indices i and j.
DSA Rust
arr.swap([1], j);Attempts:
3 left
💡 Hint
Common Mistakes
Swapping with j instead of i swaps the wrong elements.
Using low or high without context causes logic errors.
✗ Incorrect
We swap the element at index i with the element at index j to reorder elements.
3fill in blank
hardFix the error in the loop condition to continue while i is less than or equal to high.
DSA Rust
while i [1] high {
Attempts:
3 left
💡 Hint
Common Mistakes
Using < excludes the element at high index.
Using > or >= causes the loop to never run or run incorrectly.
✗ Incorrect
The loop must 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 low.
DSA Rust
arr.swap(i, [1]); low [2] 1;
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping with high instead of low causes wrong partition.
Decrementing low instead of incrementing breaks the algorithm.
✗ Incorrect
After swapping with low, increment low to move the boundary forward.
5fill in blank
hardFill all three blanks to correctly update pointers after swapping with high.
DSA Rust
arr.swap(i, [1]); high [2] 1; [3] -= 1;
Attempts:
3 left
💡 Hint
Common Mistakes
Incrementing high instead of decrementing causes infinite loop.
Not decrementing i causes skipping elements.
✗ Incorrect
After swapping with high, decrement high and also decrement i to recheck the swapped element.
