All problems
Hash Table Resize Decision
Problem
Decide whether a hash table should be resized given its load factor.
count is the number of stored entries, capacity is the number of buckets, and load_factor is the resizing threshold. The table should resize when count / capacity is greater than or equal to the threshold. A non-positive capacity always requires resizing.
Return True if the table should resize, otherwise False.
Hint
Compare count divided by capacity against the threshold with a greater-or-equal test.
Test cases
case 1
in: [7,10,0.7]
expected: true
case 2
in: [6,10,0.7]
expected: false
case 3
in: [0,4,0.75]
expected: false
case 4
in: [3,4,0.75]
expected: true
case 5
in: [0,0,0.75]
expected: true
Starter codePython
def should_resize(count, capacity, load_factor):
# Your code here
pass5 test cases · run your code against them in the editor