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

No .doc files needed, there is some steps for this the code is just okay and I t

ID: 3558708 • Letter: N

Question

No .doc files needed, there is some steps for this the code is just okay and I think its asking a question, your help is appreciated thank you!

lab gives students to write a program to perform sorts on integer arrays so that the integers are arranged from smallest to largest. Copy and paste the code below in a filename LastFirst_.lab82.cpp (e.g. DoeJoe_lab82.cpp) and save it in Lab 8 folder, Bring in the LastFirst_lab82.cpp program from the Lab 8 folder. Re-write the sort program (and save it as LastFirst_lab82a.cpp ) so that it orders integers from largest to smallest rather than smallest to largest. Take a screen shot of the output. Save it with your comments in a filename LastFirst_lab82.doc (e.g. DoeJoe_lab82.doc) o Modify your program (and save it as LastFirst_lab82b.cpp ) so that it prints the array at each step of the algorithm. Try sorting the array 23 0 45 -3 -78 1 -1 9 by hand using whichever algorithm you chose. Then have your program do the sort. Does the output match what you did by hand? Take a screen shot of the output. Insert it with your comments in LastFirst_lab82.doc. Submit the revised LastFirst_lab82a.cpp, LastFirst_lab82b.cpp and LastFirst_lab82.doc by uploading them here, he following is the code to be used:

Explanation / Answer



Output:

  #include <iostream>    using namespace std;        // function prototypes        void selectionSortArray(int [], int);    void displayArray(int[], int);    const int SIZE = 8;        int main()    {            int values[SIZE] = {23, 0, 45, -3, -78, 1, -1, 9};                  cout << "The values before the selection sort is performed are:" << endl;            displayArray(values,SIZE);                selectionSortArray(values,SIZE);            cout << "The values after the selection sort is performed are:" << endl;            displayArray(values,SIZE);                return 0;    }        //******************************************************************    //                      displayArray    //    // task:              to print the array    // data in:       the array to be printed, the array size    // data out:      none    //    //******************************************************************        void displayArray(int array[], int elems)    // function heading    {                                                          // Displays array            for (int count = 0; count < elems; count++)                    cout << array[count] << "  ";          cout << endl;    }        //******************************************************************    //                      selectionSortArray    //    // task:              to sort values of an array in ascending order    // data in:       the array, the array size    // data out:      the sorted array    //    //******************************************************************            void selectionSortArray(int array[], int elems)    {            int seek;      //array position currently being put in order            int minCount;  //location of smallest value found            int minValue;  //holds the smallest value found                for (seek = 0; seek < (elems-1);seek++)  // outer loop performs the swap                                                       // and then increments seek            {                    minCount = seek;                    minValue = array[seek];                    for(int index = seek + 1; index < elems; index++)                {                      // inner loop searches through array                              // starting at array[seek] searching                              // for the smallest value. When the                              // value is found, the subscript is                              // stored in minCount. The value is                              // stored in minValue.                                if(array[index] > minValue)                            {                                    minValue = array[index];                                    minCount = index;                  }                }                                                        array[minCount] = array[seek];                    array[seek] = minValue;                }    }    
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote