Question: Exercise 2 (5 pts) Implement both algorithms and write a test driver that does the following: 1. Creates a 100,000 element array with values in
Exercise 2 (5 pts) Implement both algorithms and write a test driver that does the following: 1. Creates a 100,000 element array with values in ascending order from 0 to 99,999, respec- tively 2. Calls the iterative method and prints empirically the time to find the position of the maximum element (99,999). 3. Calls the recursive method and prints empirically the time to find the position of the maximum element (99,999). Does it complete executing? 4. Comment on the execution times. Which algorithm took longer to run empirically? NOTE: In Java, use System.nanoTime(). In Python 3, use timeit(). In C++, use high_resolution_clock. In C, use clock(). In C#, use System.Diagnostics. Stopwatch
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
