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)

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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

#include<iostream>
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 IsArrayPrimeIter\n";

   for(int i=0;i<n;i++){
       if(arr[i]==1){
           cout<<"Leaving IsArrayPrimeIter\n";
           return false;
       }

       for(int j=2;j*j<=arr[i]; j++){
           if(arr[i]%j == 0){
               cout<<"Leaving IsArrayPrimeIter\n";
               return false;
           }
       }
   }

   cout<<"Leaving IsArrayPrimeIter\n";
   return true;
}

bool IsArrayPrimeRecur(int *arr, int n){
   cout<<"Entering IsArrayPrimeRecur\n";

   if(n==0){
       cout<<"Leaving IsArrayPrimeRecur\n";
       return true;
   }

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

   cout<<"Leaving IsArrayPrimeRecur\n";
   return false;
}

int main(){

cout<<"Enter number of elements(max = 16): ";
   int n; cin>>n;
   if(n > SORT_MAX_SIZE){
       cout<<"INVALID INPUT!! aborting...";
       return 0;
   }

   int *arr = new int[n];
   cout<<"Enter the array elements[input range : (1 to 99 inclusive)] : \n";
   for (int i = 0; i < n; ++i) {
       cin>>arr[i];
       if(arr[i] > 99 or arr[i]<1){
           cout<<"INVALID INPUT!! aborting...";
           return 0;
       }
   }

   if(IsArrayPrimeIter(arr,n)){
       cout<<"Prime Array using iteration\n";
   }else{
       cout<<"Not a Prime Array using iteration\n";
   }
cout<<"\n";
   if(IsArrayPrimeRecur(arr,n)){
       cout<<"Prime Array using recursion\n";
   }else{
       cout<<"Not a Prime Array using recursion\n";
   }

   delete[] arr;

   return 0;
}

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
Transcribed Image 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
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
Transcribed Image 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
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY