def gen_binary_str(n, bitstr, ret):
    """
    Generate all binary strings of length n
    """
    if n > 0:
        gen_binary_str(n-1, bitstr + '0', ret)
        gen_binary_str(n-1, bitstr + '1', ret)
    else:
        ret.append(bitstr)
    return ret