I've been given a homework assignment to make a function to check whether 2 given arrays with the same given size have exactly the same set of elements.My function seems to be working but I feel like I don't use the principles of recursion properly in my function.I'm not allowed to use dictionary like data structures or sorts of all kinds.Could you think of a simpler recursive approach to this problem?bool sameElements(int Arr1[], int Arr2[], int size) {    bool found; // flag to indicate whether element from Arr1 has been found in Arr2     found = false;    //base case    if (size == 1) {        if (Arr1[0] == Arr2[0])             return true;        else            return false;    }//if    else { //size != 1        int i; //index for loop        for (i = size - 1; i >= 0 && !found ; i--) {            if (Arr2[i] == Arr1[size-1]) { // check existence of element in Arr1                swapInArray(Arr2, i, (size - 1)); // swap elements                found = true;             }//if        }//for        if (found)            sameElements(Arr1, Arr2, size - 1); // send to recursion with size-1        else            return false;    }//else}//sameElementsvoid swapInArray(int arr[], int i, int j) {    int temp; // temp value to hold arr[i]    temp = arr[i];    arr[i] = arr[j];    arr[j] = temp; }//swapInArray
Check if 2 arrays have (exactly) the same elements recursively
c++;array;recursion;homework
I think the general approach is good. The function is a bit simpler when you take size == 0 as the base case. I also reformatted your code a bit and removed unnecessary comments:bool sameElements(int Arr1[], int Arr2[], int size) {    if (size == 0) {        return true;    }    for (int i = size - 1; i >= 0; i--) {        if (Arr2[i] == Arr1[size-1]) {             swapInArray(Arr2, i, (size - 1));             return sameElements(Arr1, Arr2, size - 1)         }    }    return false;}void swapInArray(int arr[], int i, int j) {    int temp = arr[i];    arr[i] = arr[j];    arr[j] = temp;}Some things I recommend to make your code easier to read:Use comments only if they are really needed. Usually a comment is and indicator that something can be expressed more clearly in the code itself.Join declarations and assignments. E.g. int temp = arr[i] instead of two separate lines.Declare variables where they are used. In your original code bool found = false could be moved inside the block containing the for loop.Make use of the ternary if-operator, [boolean expression] ? [true part] : [false part] to compact your code where appropriate. This is of course also a matter of personal taste, but I think in this particular case it improved readability of the code.