0% found this document useful (0 votes)
26 views1 page

Data Structures (IT205) (July-November, 2013) : Assignment 4 Due:29 September, 2013

This document outlines an assignment for a data structures course. It includes 4 questions: 1) implement counting sort, 2) arrange elements according to a described algorithm similar to counting sort, 3) implement radix sort, and 4) implement a variant of radix sort where each digit position uses a different ordering of the elements {1, ..., k}.

Uploaded by

diptanshujain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views1 page

Data Structures (IT205) (July-November, 2013) : Assignment 4 Due:29 September, 2013

This document outlines an assignment for a data structures course. It includes 4 questions: 1) implement counting sort, 2) arrange elements according to a described algorithm similar to counting sort, 3) implement radix sort, and 4) implement a variant of radix sort where each digit position uses a different ordering of the elements {1, ..., k}.

Uploaded by

diptanshujain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Data Structures (IT205)

(July-November, 2013):
Assignment 4
Due:29th September, 2013

1. Write a program to implement counting sort.


2. Write code similar to counting sort to arrange n elements from a fixed
set {1, . . . , k} according to the following description. If the frequencies
of the elements are {f1 , . . . , fk }, then let fmin be the minimum non-zero
frequency. The initial k 0 × fk elements of the output array must contain
fmin occurrences of 1 (assuming the frequency of 1 is not zero), followed
by fmin occurrences of 2 (again, assuming the frequency of 2 is not zero)
and so on upto fmin occurrences of element k. Here k 0 is the number of
elements among {1, . . . , k} which have non-zero frequency. For elements
of frequency zero, there is nothing to place in the output array.
After this, reduce the frequency fmin from the original frequency of each
of the k elements and repeat the procedure using the new value of fmin
and the new set of non-zero frequency elements to continue placing them
in the next subsequent positions of the output array till all the elements
are placed.
The algorithm must be stable for equal value elements.
3. Write code for radix sort.
4. Write a variant of radix sort where each digit is from the elements {1, . . . , k}
but for the ith digit, the increasing order of elements is beginning from
element value i using cyclic/modulo arithematic. Thus for the right-most
position the minimum element is 1 as usual. The order is 1,. . . , k. For
the second position we have 2 < 3 < · · · < k < 1 for the third position we
have 3 < · · · < k < 1 < 2. Can the idea used to translate counting sort to
radix sort be adapted to this routine?

You might also like