def update_nodes(ni, w, limit, e):
    """Update node index base on w, limit and e"""
    r = 2**(limit-e)
    for i in range(len(ni)):
        if w[i]: ni[i] += 1
        else: ni[i] += r
    return ni