def calculate_bucket_level(k, b):
    """
    Calculate the level in which a 0-based bucket
    lives inside of a k-ary heap.
    """
    assert k >= 2
    if k == 2:
        return log2floor(b+1)
    v = (k - 1) * (b + 1) + 1
    h = 0
    while k**(h+1) < v:
        h += 1
    return h
def calculate_bucket_level ( k , b ) : assert k >= 2 if k == 2 : return log2floor ( b + 1 ) v = ( k - 1 ) * ( b + 1 ) + 1 h = 0 while k ** ( h + 1 ) < v : h += 1 return h
Calculate the level in which a 0-based bucket
    lives inside of a k-ary heap.