Answered step by step
Verified Expert Solution
Question
1 Approved Answer
//Can you write algorithm and comment for the fllowing C++ code. The form of algorithm and comment show in the picture. void bubbleSort(int a[], int
//Can you write algorithm and comment for the fllowing C++ code. The form of algorithm and comment show in the picture.
void bubbleSort(int a[], int size) {
int ans = 0;
int t;
int ant = 0;
int flag = 0;
for (int i = 0; i
for (int j = 0; j
ans++;
if (a[j] > a[j + 1]) {
t = a[j];
a[j] = a[j + 1];
a[j + 1] = t;
ant++;
flag = 1;
}
}
}
cout
for (int i = 0; i
cout
}
cout
if(size==27)
ans=341;
if (!flag) {
cout
}
else {
cout
}
cout
}
7 using namespace std; ALgorithe: that checks what range a given NPG folls into . 1. Take the mpg value passed to the function. 11 12 13 14 15 16 Comments (10 points) 2 Check f tt is greater than se If yes, then print "Nice Job . If not, then check f t ts greater than 25 Alorithm If yes, then print "Not great, but oay 4. If not, then print "So bad, so very, very bad (10 points) Input parometers: iles per gollon (Float type 18Output:dfferent string bosed on three cotegortes of G:50, 25-49, and Less than 25 Returns: nothing 21 23 void checkPG(Float mpg) 50) check f the Input volue ts greater than 5e 25 26 27 28 29 30 31 32 cout ee "Nice job e endl; 7 output message lse if(ng25) 7/ff not, check f is greater than 25 coutStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started