please convert the code to C language // C++ program to find minimum deletion // to make all elements same #include using namespace std; int minimum_no_of_deletion(vector arr, int n) { //create a hash table where for each key //the hash function is h(x)=x //we will use stl map as hash table and //will keep frequencies stored //so say two keys are mapping to the same location,
please convert the code to C language
// C++ program to find minimum deletion
// to make all elements same
#include <bits/stdc++.h>
using namespace std;
int minimum_no_of_deletion(
{
//create a hash table where for each key
//the hash function is h(x)=x
//we will use stl map as hash table and
//will keep frequencies stored
//so say two keys are mapping to the same location,
//then the location will have value 2
//instead of the keys itself
map<int, int> hash;
for (auto i : arr) { //for each number
hash[i]++;
}
//now to make all elements same
//we need to keep only the keys with
//maximum frequency
//we need to delete the other keys
//so find the key with max frequency
int maxfreq = 0;
for (auto it = hash.begin(); it != hash.end(); it++) {
if (it->second > maxfreq) {
maxfreq = it->second;
}
}
//so we need to dlete rest of
//the elements n-maxfreq
return n - maxfreq;
}
int main()
{
int n;
cout << "Enter number of elements\n";
cin >> n;
vector<int> arr(n, 0);
cout << "Input the array elements\n";
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
cout << "Minimum number of deletion required to make all elements same is: ";
cout << minimum_no_of_deletion(arr, n) << endl;
return 0;
}
Output:
![Enter number of elements
8
Input the array elements
12 13 14 12 12 15 12 17
Minimum number of deletion required to make all elements same is: 4](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F69aa193b-87a6-4ad2-b09f-af122462b6cb%2Fe7f47e86-33a2-483d-a218-4ab72141e5ef%2Frfwypq_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)