Propagation cost algorithm for c