C For this exercise create 2 programs defined in files slowc
[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.
Solution
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![[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 sort [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 sort](/WebImages/15/c-for-this-exercise-create-2-programs-defined-in-files-slowc-1023378-1761529565-0.webp)