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

Write a C++ program that creates an array of 100 elements that are populated by

ID: 3844790 • Letter: W

Question

Write a C++ program that creates an array of 100 elements that are populated by random numbers between 0 and 999 (hint: you can re­use a lot of code from the first problem!) Run the ascending sort algorithm on it ­ use the one demonstrated in class (and found on our website under the “demos” section). Measure how long it took to run the sort. To make such a measure, use a Linux OS tool called time that measures how long a program takes to execute. To use time, do the following: step a. Compile your program. Let us assume that the executable (object) file is called Prob3. step b. At the Linux prompt (%), type: time ./Prob3 and hit return. step c. The program will be executed and, at the bottom, you will see a print out of 3 lines showing execution times (use the first entry ­ “real” ­ for this homework). Now modify the program so that the array size is 1,000 elements and re­run the sort algorithm. Again, measure how long it took to run the sort ­ was it noticeably longer? If so, by what (approximate) factor? One more time, modify the program for an array size of 10,000 elements, re­run and time the sort and answer the same questions.

Explanation / Answer

#include #include using namespace std; int input (int []); int output (int []); int main () { int rNumb[50]; input (rNumb); output (rNumb); } int input (int x[]) { srand(time(0)); for(int i=0; i
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