in GATE retagged by
498 views
2 votes
2 votes

A radix sort is to be used to sort the file of non-negative integers shown below into ascending order. What would the order of the numbers be after one pass of the algorithm?
$12$ $37$ $42$ $9$ $5$ $7$ $50$ $40$ $45$ $92$
 

  1.   $12$  $37$  $42$  $40$  $45$  $5$  $50$    $7$    $9$  $92$      
  2.   $50$  $40$  $12$  $42$  $92$  $5$  $45$  $37$    $7$    $9$     
  3.   $40$  $50$  $12$  $42$  $92$  $5$  $45$  $37$    $7$    $9$     
  4.   $40$  $50$  $12$  $42$  $92$  $5$  $45$    $7$  $37$    $9$
in GATE retagged by
by
498 views

1 Answer

4 votes
4 votes
Best answer

In Radix Sort, we start sorting numbers by their digits at a specific place. We start from one's place, then move to ten's place, and so on.

So, after 1st pass, the array will be sorted by their digit at one's place, i.e. by their least significant digit. And to sort the digits we use a stable sort. It must be a stable sort for radix sort to work properly.

After 1st pass:

(B) 50 40 12 42 92 5 45 37 7 9

P.S. For single digit numbers, you can write them as 05, 07, etc. to avoid confusion.

selected by
Answer:

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

64.3k questions

77.9k answers

244k comments

80.0k users