QuestionQuestion

In this lab, you will sort an array of constant integers in place using three different techniques.
1. reset function will be used to set the array to the original numbers.
2. displayIntArray will be used to printout the content of the sorted array.
3. displayPtrArray will be used to printout the pointer addresses of each of the elements of the pointer array. This must be done before and after the each sort is done (no text should be displayed in this function).
4. Bubble sort function will be called which will use the bubble sort techinque to sort the content of the pointer array such that when you iterate through the array and print out its content, the integers will be in ascending sorted order.
Everytime you change the content of the elements of the pointer array, print out the entire pointer array by calling the void displayPtrArrayDeref function. But only display the contents when the elements in the aray have changed.
5. The Selection sort (the code for the function is given) function will be called which will use the selection sort techinque to sort the content of the pointer array such that when you iterate through the array and print out its content, the integers will be in ascending sorted order.
Everytime you change the content of the elements of the pointer array, print out the entire pointer array by calling the void displayPtrArrayDeref function. But only display the contents when the elements in the aray have changed.
6. The Insertion sort function will be called which will use the insertion sort techinque to sort the content of the pointer array such that when you iterate through the array and print out its content, the integers will be in ascending sorted order.
Everytime you change the content of the elements of the pointer array, print out the entire pointer array by calling the displayPtrArrayDeref function. But only display the contents when the n elements in the aray have changed.
7. The last line will contain the phrase “Sorting Complete” and your name.
8. Your output should match the following pages.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
using namespace std;

/* 1. Assign each int element address to elements of the array of int
* pointers in such a way
* that the address of the first element in the int array is assigned
* to the first element of the pointer array,
* the address of the second element in the int array is assigned
* to the second element of the pointer array, and so on.
*/
void reset(const int start_num[], const int *ptr[], int size) {
    for (int i = 0; i < size; i++) {
       // ptr[i] contain the address of start_num[i]
       // we could use ptr[i] = &start_num[i];
       // but it may be hard to understand than this expression
       ptr[i] = start_num + i;
    }

}

/* 2. use a loop to display the content of the num array */
void displayIntArray(const int num[], int size) {
    cout << " ";
    for (int i = 0; i < size; i++) {
       cout << setw(8) << right << num[i];
    }
    cout << "\n";
}...

By purchasing this solution you'll be able to access the following files:
Solution.cpp.

50% discount

Hours
Minutes
Seconds
$30.00 $15.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats