Question: PYTHON: 4. (4 points) Compare the execution times of your k_subsets naive and k_subsets_better func- tions by timing both using the same input. Because the

PYTHON:

PYTHON: 4. (4 points) Compare the execution times of your k_subsets naive

4. (4 points) Compare the execution times of your k_subsets naive and k_subsets_better func- tions by timing both using the same input. Because the naive version requires exponential time, you won't need a very large input to notice slow execution. You can use Python's process_time function, located in the time module: import time start_time = time.process_time() # code to time here end_time = time.process_time () # elapsed time in seconds is (end_time - start_time) As a reference point, the running time on my laptop (Core i7-6700HQ, 2.6 GHz, Win10 Pro) for finding all 5-subsets of a 20-element list was about 10 seconds for the naive solution and 0.3 seconds for the better solution. The exact execution times will vary greatly depending on your hardware, but there should be a large relative difference between the two algorithms

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!