Name: _____________________________ 6 Digit StudentID: ___ ___ ___ ___ ___ ___

Worksheet 06: Divide and Conquer

In the code below note the call to arrayMutatingCombineStep(array, min, maxExclusive) which mutates the array.

void dnc(String[] array, int min, int maxExclusive) {
    if (isBaseCase(min, maxExclusive)) {
        handleBaseCase(min, maxExclusive);
    } else {
        int mid = midpoint(min, maxExclusive);
        Future f = void_fork(() -> {
            dnc(array, min, mid);
        });
        dnc(array, mid, maxExclusive);
        join(f);
        arrayMutatingCombineStep(array, min, maxExclusive);
    }
}
  • What is the data?
  • Is it shared?
  • Is it mutable?
  • Is it being mutated?
  • Is there a data race?
  • Why or why not?
  • Post Lecture

    Synthesize today's class session

     

     

    What is unclear?