Embercode
✕
SortingQuick quiz

Radix

6 questions. Covers Radix sort in Python.

Questions 1 to 5 of 6

  1. 1. Put the steps of one digit pass of radix sort in the order the code runs them.

    Use the arrows to put the steps in order.

    1. 1.For each value in the current order, compute its digit and append it to that digit's list.
    2. 2.Create ten empty lists, one for each digit from 0 to 9.
    3. 3.Read the lists from 0 to 9 and write the values back into the list.
  2. 2. Put these steps for finding the hundreds digit of 4071 in order.

    Use the arrows to put the steps in order.

    1. 1.Take 40 % 10, which gives the digit 0.
    2. 2.Use the place value 100.
    3. 3.Divide 4071 by 100 with integer division, which gives 40.
  3. 3. What does this print? The digit_pass function is the one from the lesson. ``python def digit_pass(a, place): buckets = [[] for _ in range(10)] for value in a: buckets[(value // place) % 10].append(value) k = 0 for bucket in buckets: for value in bucket: a[k] = value k += 1 a = [21, 3, 15, 30, 12] digit_pass(a, 10) print(a) ``
  4. 4. What does this program print? ``python max_value = 1000 passes = 0 place = 1 while max_value // place > 0: passes += 1 place *= 10 print(passes) ``
  5. 5. Which list method adds a value to the back of a bucket, so the first value added is the first one read back out?

    Type your answer.

3 question(s) left on this page.

Typed answers ignore extra spaces and, for most questions, capital letters.