Question: I need a C code for this problem An array of integers, arr, of size N is defined as {a0, a1, ..., aN-1} Complete the

I need a C code for this problem

An array of integers, arr, of size N is defined as {a0, a1, ..., aN-1}

Complete the customSort function declared in your editor. It must take arr as a parameter, sort its elements in order of ascending frequency, and then print each element of the sorted array as a new line of output. If 2 or more elements have the same frequency, this subset of elements should be sorted in non-decreasing order.

Input Format

The locked stub code in the editor handles reading input from stdin, assembling it into an array of integers (arr), and calling the sort function. The first line of input contains an integer, N (the number of elements). Each line i of the N subsequent lines describes array element arr[i].

Constraints

1 =< N =< 2 x 10^5

1 < ai < 10^6 Output Format

Your customSort function should print the sorted (in order of non-decreasing frequency) elements of array arr. If 2 or more elements have the same frequency, this subset of elements should be sorted in non-decreasing order. Each element must be printed on a new line.

Sample Input 1

5

3

1

2

2

4

Sample Output 1

1

3

4

2

2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!