Question
from timeit import timeit from linked_list import LinkedList NUM_TRIALS = 3000 # The number of trials to run. SIZES = [1000, 2000, 4000, 8000, 16000]
from timeit import timeit from linked_list import LinkedList
NUM_TRIALS = 3000 # The number of trials to run. SIZES = [1000, 2000, 4000, 8000, 16000] # The list sizes to try.
def profile_len(list_class: type, size: int) -> float: """Return the time taken to call len on a list of the given class and size.
Precondition: list_class is either list or LinkedList. """ # TODO: Create an instance of list_class containing
# TODO: call timeit appropriately to check the runtime of len on the list. return 0.0
if __name__ == '__main__': for list_class in [LinkedList]: # Try each list size for s in SIZES: time = profile_len(list_class, s) print(f'[{list_class.__name__}] Size {s:>6}: {time}')
Step 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