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

Counting Sort Implementation in C++

The document discusses implementing sorting by counting for a given vector. It includes code to take in a vector of numbers, count the frequency of each unique number, then output each number based on its counted frequency.

Uploaded by

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

Counting Sort Implementation in C++

The document discusses implementing sorting by counting for a given vector. It includes code to take in a vector of numbers, count the frequency of each unique number, then output each number based on its counted frequency.

Uploaded by

Antonia Petrescu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

// Se da un vector. Sa se implementeze sortarea prin numarare.

//

#include <iostream>

using namespace std;

const int MAX = 618;

int n;

int frq[MAX];

int main()

{ cin >> n;

for (int i = 0; i < n; i++)

int x;

cin >> x;

frq[x]++;

for (int i = 0; i < MAX; i++)

while (frq[i]--)

cout << i << ' ';

cout << '\n';

return 0;

You might also like