Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please help me convert this c++ code into pseudo code so i can better understand

ID: 3539778 • Letter: P

Question

please help me convert this c++ code into pseudo code so i can better understand what it happening when it is executed.


#include <iostream>


using std::cout;


using std::endl;


#include <cstdlib>


using std::rand;


using std::srand;


#include <ctime>


using std::time;


// Function Prototype


void selectionSort( int [], int );


int main()


{


// Given variable and constant declarations


const int SIZE = 10;


const int MAXRANGE = 1000;


int sortThisArray[ SIZE ] = {};


srand( time( 0 ) );


// Fill array with random numbers between 1-1000



for(int i=0;i<SIZE;i++)

sortThisArray[i]=rand()%MAXRANGE+1;


// Display the unsorted array



cout<<"Unsorted array is ";

for(int i=0;i<SIZE;i++)

cout<<sortThisArray[i]<<" ";

cout<<endl;



// Call the sorting array function


selectionSort( sortThisArray, SIZE );


// Display the sorted array

cout<<"Sorted array is ";

for(int i=0;i<SIZE;i++)

cout<<sortThisArray[i]<<" ";

cout<<endl;


system("pause");

return 0; // indicates successful termination


} // end main

void selectionSort( int a[],int n )

{ int i,j,min,index,temp;

for(i=0;i<n-1; i++)

{index=i;

min=a[i];

for(j=i+1;j<n;j++)

{if(min>a[j])

{index=j;

min=a[j];

}

}

temp=a[i];

a[i]=a[index];

a[index]=temp;

  

  

}

}

Explanation / Answer

main()

{

for i in 10:

fill the array with random numbers which are less than 1000;

for i in 10:

print the unsorted array;

selectionsort(array);

for i in 10:

print the sorted array;


}


selectionsort(array)

{

for i in 10:

for j in (i+1,10):

{

if(array[i]>array[i+1])

{

swap (array[i],array[j]);

}

}