Efficient Algorithms for Prefix and General Prefix Computations on Distributed Shared Memory Systems with Applications