please convert the code to C language   //C++ program to check if two arrays  //are equal or not #include using namespace std; bool similar_array(vector arr1, vector arr2) {     //create teo different hash table where for each key      //the hash function is h(arr[i])=arr[i]     //we will use stl map as hash table and      //will keep frequency stored     //so say two keys arr[0] and arr[5] are mapping to      //the same location, then the location will have value 2     //instead of the keys itself     //if two hash tables are exactly same then      //we can say that our arrays are similar     map hash1;     map hash2;     //for each number     for (int i = 0, j = 0; i < arr1.size(); i++, j++) {         hash1[arr1[i]]++;         hash2[arr2[i]]++;     }     //now check whether hash tables are exactly same or not     for (auto it = hash1.begin(), ij = hash2.begin(); it != hash1.end() && ij != hash2.end(); it++, ij++) {         if (it->first != ij->first || it->second != ij->second)             return false;     }     //so ans will be updated maxdiff     return true; } int main() {     int n, m;       cout << "Enter number of elements for array1 & array2\n";     cin >> n;     //arrays having equal sum     vector arr1(n, 0);     vector arr2(n, 0);     cout << "Input the array elements\n";     for (int i = 0; i < n; i++) {         cin >> arr1[i];         cin >> arr2[i];     }       if (similar_array(arr1, arr2))         cout << "The arrys are equal";     else         cout << "The arrys are not equal";     return 0;         }   Output:

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

please convert the code to C language

 

//C++ program to check if two arrays 
//are equal or not

#include <bits/stdc++.h>
using namespace std;

bool similar_array(vector<int> arr1, vector<int> arr2)
{
    //create teo different hash table where for each key 
    //the hash function is h(arr[i])=arr[i]
    //we will use stl map as hash table and 
    //will keep frequency stored
    //so say two keys arr[0] and arr[5] are mapping to 
    //the same location, then the location will have value 2
    //instead of the keys itself
    //if two hash tables are exactly same then 
    //we can say that our arrays are similar
    map<int, int> hash1;
    map<int, int> hash2;

    //for each number
    for (int i = 0, j = 0; i < arr1.size(); i++, j++) {
        hash1[arr1[i]]++;
        hash2[arr2[i]]++;
    }

    //now check whether hash tables are exactly same or not
    for (auto it = hash1.begin(), ij = hash2.begin(); it != hash1.end() && ij != hash2.end(); it++, ij++) {
        if (it->first != ij->first || it->second != ij->second)
            return false;
    }

    //so ans will be updated maxdiff
    return true;
}

int main()
{
    int n, m;
 
    cout << "Enter number of elements for array1 & array2\n";
    cin >> n;

    //arrays having equal sum
    vector<int> arr1(n, 0);
    vector<int> arr2(n, 0);
    cout << "Input the array elements\n";

    for (int i = 0; i < n; i++) {
        cin >> arr1[i];
        cin >> arr2[i];
    }
 
    if (similar_array(arr1, arr2))
        cout << "The arrys are equal";
    else
        cout << "The arrys are not equal";

    return 0;        
}

 

Output:

 

Enter number of elements for array1 & array2
6
Input the array elements
1 2 1 3 2 1
2 2 3 1 1 1
The arrys are equal
Transcribed Image Text:Enter number of elements for array1 & array2 6 Input the array elements 1 2 1 3 2 1 2 2 3 1 1 1 The arrys are equal
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Operations of Linked List
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education