Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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:
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 algorithmsStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started