Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to get the maximum number in the list for Radix Sort.
DSA Python
max_num = max(arr) if arr else [1]
Attempts:
3 left
💡 Hint
Common Mistakes
Using None causes errors when comparing numbers.
Using -1 may cause incorrect sorting if numbers are positive.
✗ Incorrect
If the list is empty, the maximum number should be 0 to avoid errors.
2fill in blank
mediumComplete the code to extract the digit at the current place value.
DSA Python
digit = (num // [1]) % 10
Attempts:
3 left
💡 Hint
Common Mistakes
Using fixed numbers like 10 or 1 instead of the variable place.
Using 0 causes division errors.
✗ Incorrect
We divide by the current place value to get the digit at that place.
3fill in blank
hardFix the error in the loop that updates the place value for Radix Sort.
DSA Python
place = [1] * 10
Attempts:
3 left
💡 Hint
Common Mistakes
Using 10 alone resets place to 10 every time.
Using max_num or num causes incorrect place updates.
✗ Incorrect
We multiply the current place value by 10 to move to the next digit place.
4fill in blank
hardFill both blanks to create the buckets and append numbers based on the current digit.
DSA Python
buckets = [[] for _ in [1]] buckets[digit].[2](num)
Attempts:
3 left
💡 Hint
Common Mistakes
Using extend instead of append adds each digit as separate elements.
Using list(range(10)) works but is less common than range(10).
✗ Incorrect
We create 10 empty buckets for digits 0-9 and append numbers to the correct bucket.
5fill in blank
hardFill all three blanks to rebuild the list from buckets after each digit sorting pass.
DSA Python
arr = [[1] for bucket in buckets for [2] in bucket] [3]
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names inconsistently.
Printing buckets instead of arr does not show the sorted list.
✗ Incorrect
We flatten the buckets back into arr using num, and print arr to see the sorted state.
