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

[C++] For this exercise, create 2 programs defined in files slow.cpp and fast.cp

ID: 3931289 • Letter: #

Question

[C++]

For this exercise, create 2 programs defined in files slow.cpp and fast.cpp.

In slow.cpp, generate a random array of size 200,000 and pass it to your sorting algorithm. Run the program and observe that it never ends. Press CTRL C to terminate the process.

In fast.cpp, generate a random array of size 200,000 and pass it to the sort routine that is part of the C++ standard library. The following code shows how you would call the sort function on an array a or size 200,000.

If the above line fails to compile, you may need to include the algorithm header as follows.

Run fast.cpp and notice how quickly it terminates. The reason for this is that the sorting function in the standard library is using is more efficient than the one you produced. How quickly algorithms terminate is within an area of computer science referred to as complexity theory.

Explanation / Answer

Find the maximum element in an array which is first increasing and then decreasing Input: arr[] = {8, 10, 20, 80, 100, 200, 400, 500, 3, 2, 1} Output: 500 Input: arr[] = {1, 3, 50, 10, 9, 7, 6} Output: 50 Corner case (No decreasing part) Input: arr[] = {10, 20, 30, 40, 50} Output: 50 Corner case (No increasing part) Input: arr[] = {120, 100, 80, 20, 0} Output: 120

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