Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Python Implement a Statistics class in your dictionary.py file with the following methods: load_statistics(self, hash_base: int, table_size: int, filename: str, max_time: int) -> Tuple,

image text in transcribedimage text in transcribedIn Python

Implement a Statistics class in your dictionary.py file with the following methods: load_statistics(self, hash_base: int, table_size: int, filename: str, max_time: int) -> Tuple, which creates a new dictionary with hash_base and table_size and returns the tuple (words, time, collision_count, probe_total, probe_max, rehash_count) where: o words is the number of words added to the table o time is the time taken for load_dictionary to complete if None, which, for each possible combination of values in the table below, uses load_statistics to time how long it takes for Load_dictionary to run. For each combination a line should be printed to output_task2.csv which contains: o The name of the dictionary file read. o The TABLESIZE and b used. o The number of words added to the hash table. o The four counters computed in statistics. Either the time taken to run load_dictionary, or max_time, whichever is smaller. Combinations b TABLESIZE Filename 1 250727 english_large english_small 27183 402221 250726 1000081 french class LinearProbeHashTable (Generic[T]): Linear Probe Hash Table constants: MIN_CAPACITY: smallest valid table size DEFAULT_TABLE_SIZE: default table size used in the __init__ DEFAULT_HASH_TABLE: default hash base used for the hash function PRIMES: list of prime numbers to use for resizing attributes: count: number of elements in the hash table table: used to represent our internal array hash_base: base prime used in hash function table_size: current size of the hash table next_prime: next prime number to use when resizing MIN_CAPACITY = 1 DEFAULT_TABLE_SIZE = 17 DEFAULT_HASH_BASE = 31 PRIMES = [3, 7, 11, 17, 23, 29, 37, 47, 59, 71, 89, 107, 1, 163, 197, 239, 293, 53, 31, 521, 31, 76 919, 1103, 1327, 1597, 1931, 2333, 2801, 3371, 4049, 4861, 5839, 7013, 8419, 10103, 12143, 14591, 17519, 21023, 25229, 30313, 36353, 43627, 52361, 62851, 75521, 90523, 108631, 130363, 156437, 187751, 225307, 270371, 324449, 389357, 467237, 560689, 672827, 807403, 968897, 1162687, 1395263, 1674319, 2009191, 2411033, 2893249, 3471899, 4166287, 4999559, 5999471, 7199369] def __init__(self, hash_base: int = DEFAULT_HASH_BASE, table_size: int = DEFAULT_TABLE_SIZE) -> None: :complexity: 0(N) where N is the table_size self.count = 0 self.table = ArrayR(max(self.MIN_CAPACITY, table_size)) self.hash_base = hash_base self.next_prime = 0 while Linear ProbeHashTable.PRIMES[self.next_prime] Tuple, which creates a new dictionary with hash_base and table_size and returns the tuple (words, time, collision_count, probe_total, probe_max, rehash_count) where: o words is the number of words added to the table o time is the time taken for load_dictionary to complete if None, which, for each possible combination of values in the table below, uses load_statistics to time how long it takes for Load_dictionary to run. For each combination a line should be printed to output_task2.csv which contains: o The name of the dictionary file read. o The TABLESIZE and b used. o The number of words added to the hash table. o The four counters computed in statistics. Either the time taken to run load_dictionary, or max_time, whichever is smaller. Combinations b TABLESIZE Filename 1 250727 english_large english_small 27183 402221 250726 1000081 french class LinearProbeHashTable (Generic[T]): Linear Probe Hash Table constants: MIN_CAPACITY: smallest valid table size DEFAULT_TABLE_SIZE: default table size used in the __init__ DEFAULT_HASH_TABLE: default hash base used for the hash function PRIMES: list of prime numbers to use for resizing attributes: count: number of elements in the hash table table: used to represent our internal array hash_base: base prime used in hash function table_size: current size of the hash table next_prime: next prime number to use when resizing MIN_CAPACITY = 1 DEFAULT_TABLE_SIZE = 17 DEFAULT_HASH_BASE = 31 PRIMES = [3, 7, 11, 17, 23, 29, 37, 47, 59, 71, 89, 107, 1, 163, 197, 239, 293, 53, 31, 521, 31, 76 919, 1103, 1327, 1597, 1931, 2333, 2801, 3371, 4049, 4861, 5839, 7013, 8419, 10103, 12143, 14591, 17519, 21023, 25229, 30313, 36353, 43627, 52361, 62851, 75521, 90523, 108631, 130363, 156437, 187751, 225307, 270371, 324449, 389357, 467237, 560689, 672827, 807403, 968897, 1162687, 1395263, 1674319, 2009191, 2411033, 2893249, 3471899, 4166287, 4999559, 5999471, 7199369] def __init__(self, hash_base: int = DEFAULT_HASH_BASE, table_size: int = DEFAULT_TABLE_SIZE) -> None: :complexity: 0(N) where N is the table_size self.count = 0 self.table = ArrayR(max(self.MIN_CAPACITY, table_size)) self.hash_base = hash_base self.next_prime = 0 while Linear ProbeHashTable.PRIMES[self.next_prime]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What roles have these individuals played in your life?

Answered: 1 week ago

Question

1. Write down two or three of your greatest strengths.

Answered: 1 week ago