IAE Academy

ISRO CS 2023 Q.25: solution and answer

ISRO 2023 · CSQ.25 · 1 mark · MCQ

What is the maximum number of comparisons needed to sort 6 items using radix sort, if each number is a 3-digit decimal number?

  1. (A)

    120

  2. (B)

    180

  3. (C)

    210

  4. (D)

    360

See the question in the paper

Answer and solution

ANSWER

The maximum number of comparisons is , so the answer is (B).

Official answer: BSource: ISRO's revised and final answer key of 16 February 2024

  1. Radix sort (least significant digit first) does one pass per digit position. A 3-digit decimal number has positions, so there are passes.

  2. In each pass, an item is placed in one of the digit buckets (0 to 9). In the worst case its digit is checked against each of the 10 possible digit values, which costs comparisons per item.

  3. One pass over items therefore costs at most comparisons.

  4. Over all passes the maximum is .

  5. This agrees with the cost model in its usual form, where the work per pass grows with the number of items times the number of possible digit values.

  6. Check against the options: and are not whole multiples of , and would need buckets, which a decimal digit does not have. Only fits.

KEY IDEA

Radix sort makes one pass per digit, and each pass handles every item against the possible digit values, so the count is with , , .

WATCH OUT FOR

Counting only operations, or using or buckets, instead of multiplying passes, items and the 10 possible decimal digit values.

From the ISRO CS 2023 paper. Every question of this paper · The full paper (PDF, ISRO) · All 3 ISRO Sorting & hashing questions, with notes