Can you put the comments and make a pseudocode for three functions not the main int. #include using namespace std; const int SORT_MAX_SIZE = 16; // helper function bool isPrime(int n, int i = 2) {...


Can you put the comments and make a pseudocode for three functions not the main int.


#include
using namespace std;


const int SORT_MAX_SIZE = 16;


// helper function
bool isPrime(int n, int i = 2)
{
if(n == 1)
return false;
if(n == 2)
   return true;
if (n % i == 0)
return false;
if (i * i > n)
return true;


// Checking for next divisor
return isPrime(n, i + 1);
}


bool IsArrayPrimeIter(int *arr, int n){
   cout<"entering>


   for(int i=0;i<>
       if(arr[i]==1){
           cout<"leaving>
           return false;
       }


       for(int j=2;j*j<=arr[i];>
           if(arr[i]%j == 0){
               cout<"leaving>
               return false;
           }
       }
   }


   cout<"leaving>
   return true;
}


bool IsArrayPrimeRecur(int *arr, int n){
   cout<"entering>


   if(n==0){
       cout<"leaving>
       return true;
   }


   if(isPrime(arr[n-1])){
       return IsArrayPrimeRecur(arr, n-1);
   }


   cout<"leaving>
   return false;
}


int main(){


cout<"enter number="" of="" elements(max="16):">
   int n; cin>>n;
   if(n > SORT_MAX_SIZE){
       cout<"invalid input!!="">
       return 0;
   }


   int *arr = new int[n];
   cout<"enter the="" array="" elements[input="" range="" :="" (1="" to="" 99="" inclusive)]="" :="">
   for (int i = 0; i < n;="" ++i)="">
       cin>>arr[i];
       if(arr[i] > 99 or arr[i]<>
           cout<"invalid input!!="">
           return 0;
       }
   }


   if(IsArrayPrimeIter(arr,n)){
       cout<"prime array="" using="">
   }else{
       cout<"not a="" prime="" array="" using="">
   }
cout<>
   if(IsArrayPrimeRecur(arr,n)){
       cout<"prime array="" using="">
   }else{
       cout<"not a="" prime="" array="" using="">
   }


   delete[] arr;


   return 0;
}


Enter number of elements(max<br>Enter the array elements[input range : (1 to 99 inclusive)] :<br>2 5 9 3 41 68 52 76<br>Entering IsArrayPrimeIter<br>Leaving IsArrayPrimeIter<br>Not a Prime Array using iteration<br>16): 8<br>Entering IsArrayPrimeRecur<br>Leaving IsArrayPrimeRecur<br>Not a Prime Array using recursion<br>

Extracted text: Enter number of elements(max Enter the array elements[input range : (1 to 99 inclusive)] : 2 5 9 3 41 68 52 76 Entering IsArrayPrimeIter Leaving IsArrayPrimeIter Not a Prime Array using iteration 16): 8 Entering IsArrayPrimeRecur Leaving IsArrayPrimeRecur Not a Prime Array using recursion
Enter number of elements(max<br>Enter the array elements[input range : (1 to 99 inclusive)] :<br>7 5 2 11 23 37<br>Entering IsArrayPrimeIter<br>Leaving IsArrayPrimeIter<br>Prime Array using iteration<br>16): 6<br>Entering IsArrayPrimeRecur<br>Entering IsArrayPrimeRecur<br>Entering IsArrayPrimeRecur<br>Entering IsArrayPrimeRecur<br>Entering IsArrayPrimeRecur<br>Entering IsArrayPrimeRecur<br>Entering IsArrayPrimeRecur<br>Leaving IsArrayPrimeRecur<br>Prime Array using recursion<br>

Extracted text: Enter number of elements(max Enter the array elements[input range : (1 to 99 inclusive)] : 7 5 2 11 23 37 Entering IsArrayPrimeIter Leaving IsArrayPrimeIter Prime Array using iteration 16): 6 Entering IsArrayPrimeRecur Entering IsArrayPrimeRecur Entering IsArrayPrimeRecur Entering IsArrayPrimeRecur Entering IsArrayPrimeRecur Entering IsArrayPrimeRecur Entering IsArrayPrimeRecur Leaving IsArrayPrimeRecur Prime Array using recursion
Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here