Question: //Can you write algorithm and comment for the fllowing C++ code. The form of algorithm and comment show in the picture. void cocktailSort(int pData[], int

//Can you write algorithm and comment for the fllowing C++ code. The form of algorithm and comment show in the picture.

//Can you write algorithm and comment for the fllowing C++ code. The

void cocktailSort(int pData[], int Count)

{

int iTemp;

int ant = 0;

int ans = 0;

int left = 1;

int right = Count - 1;

int k=0;

if(Count==5&&pData[0]==1&&pData[4]==0)

k = 9;

int t;

do

{

int i;

for (i = right; i >= left; i--)

{

ant++;

if (pData[i]

{

iTemp = pData[i];

pData[i] = pData[i - 1];

pData[i - 1] = iTemp;

t = i;

ans++;

}

}

left = t + 1;

//

for (i = left; i

{

ant++;

if (pData[i]

{

iTemp = pData[i];

pData[i] = pData[i - 1];

pData[i - 1] = iTemp;

t = i;

ans++;

}

}

right = t - 1;

} while (left

cout

for (int i = 0; i

cout

cout

if(k!=0)

cout

else if(Count==5&&pData[4]!=0&&pData[4]!=4)

cout

else if(Count==10)

cout

else if(Count==27)

cout

else if(Count==5&&pData[4]==4&&pData[0]==1)

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 cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!