CPSC 626: Parallel Algorithm Design and Analysis
Homework Assignment #2
Fall 2008

Due: Thursday September 18, 2008 in class.


General Guidelines for Homework


  1. Given a sequence of numbers x1, x2, ..., xn, the prefix sums are the partial sums
    s1 = x1
    s2 = x1 + x2
    ...
    sn = x1 + x2 + ... + xn

    (a) Describe an algorithm to compute the prefix sums on a PRAM with n processors in O(log n) time. Analyze the running time of your algorithm and argue, at least informally, its correctness. Which PRAM model does your algorithm use (e.g., EREW, CREW, CRCW)? Does your algorithm require a synchronous PRAM?

    (b) Describe an algorithm to compute the prefix sums on an n processor mesh in O(sqrt(n)) time. Assume sqrt(n) is an integer. Analyze the running time of your algorithm and argue, at least informally, its correctness.

    (c) Describe an algorithm to compute the prefix sums on an n processor hypercube in O(log2 n) time (or faster). Assume n is a power of 2. Analyze the running time of your algorithm and argue, at least informally, its correctness.

  2. Repeat the previous question, but this time consider the case when p < n, i.e., the number of processors is less than the number of input elements. For the hypercube and the mesh, assume that each processor initially holds n/p input elements. Analyze the running time of your algorithms and argue, at least informally, their correctness. (If an algorithm is similar to the corresponding one from 2, you need only discuss the modifications.)