0
0
DSA Goprogramming~10 mins

Radix Sort Algorithm in DSA Go - Interactive Practice

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

Complete the code to get the digit at a given place value in Radix Sort.

DSA Go
func getDigit(num, place int) int {
    return (num / [1]) % 10
}
Drag options to blanks, or click blank then click option'
Aplace
B1
C10
Dplace * 10
Attempts:
3 left
💡 Hint
Common Mistakes
Using a fixed 10 instead of place.
Forgetting to use modulo 10 to isolate the digit.
2fill in blank
medium

Complete the code to find the maximum number in the array for Radix Sort.

DSA Go
func getMax(arr []int) int {
    max := arr[0]
    for i := 1; i < len(arr); i++ {
        if arr[i] [1] max {
            max = arr[i]
        }
    }
    return max
}
Drag options to blanks, or click blank then click option'
A>
B<
C==
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using less than operator which finds minimum instead.
Using equality operator which doesn't update max.
3fill in blank
hard

Fix the error in the counting sort step of Radix Sort to correctly count digit frequencies.

DSA Go
for i := 0; i < len(arr); i++ {
    count[(arr[i]/[1])%10]++
}
Drag options to blanks, or click blank then click option'
A10
Bplace * 10
C1
Dplace
Attempts:
3 left
💡 Hint
Common Mistakes
Using a fixed 10 instead of the variable place value.
Forgetting to use modulo 10 after division.
4fill in blank
hard

Fill both blanks to correctly build the output array in counting sort for Radix Sort.

DSA Go
for i := len(arr) - 1; i >= 0; i-- {
    index := (arr[i] / [1]) % 10
    output[count[index][2]] = arr[i]
    count[index]--
}
Drag options to blanks, or click blank then click option'
Aplace
B+ 1
C- 1
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Using +1 instead of -1 causing index out of range.
Using fixed 10 instead of place variable.
5fill in blank
hard

Fill all three blanks to complete the main Radix Sort loop controlling place values.

DSA Go
for place := 1; [1] <= maxNum; [2] {
    countingSort(arr, [3])
}
Drag options to blanks, or click blank then click option'
Aplace
Bplace <= maxNum
Cplace * 10
DmaxNum
Attempts:
3 left
💡 Hint
Common Mistakes
Using maxNum in place of loop variable in condition.
Incrementing place by 1 instead of multiplying by 10.