------------------------ HW7, due 11:59 p.m., Monday, April 15 (unless Form 4868?): 30.1-2, 3, 4, 5, 6 30.2-1, 2, 4, 5, 6, 7, 9 284 exception: Omit one of these 12, if you like. Hints for 30.2-6: Tournaments. Already have epsilon=1. Hint or uncertainty on 30.2-7: CREW actually enough? ------------------------ Setting: Linked list, with processor stationed at each node, but not in order (i.e., don't know the ranks). Goal: Determine all the ranks. ``Pointer jumping'' invariant: Maintain a distance (or other associative result) to some also-maintained ``downstream'' node. Initialization: Easy Increasing the distance: add (or whatever) Double distances at each synchronous step (subject to reaching ultimate end). Therefore, get *all* ultimate distances (or whatevers) in time about log n. Total ``work'': O(n log n). (Improvable to just O(n) (the sequentially sufficient amount), but not now.) Sufficient model: EREW EW clear, but ER requires some care (e.g., no shared destinations). ------------------------ Easy generalization: For *any* associative operation, all suffix results. Moreover, can reverse list in time O(1), or adapt in other still-EREW ways. (E.g., can store results at link *heads* rather than tails.) Might call this ``parallel prefix computation'' or ``parallel scan.'' ------------------------ Preview of scan work reduction--in array. The trick: One processor at start of each aligned block of log n inputs. Phase 1: Each such ``captain'' sequentially compute his block's sum. Phase 2: Prefix sums of these sums (the correct answers for the captains). Phase 3: Each captain sequentially fill in his block's other answers. Each phase requires only O(log n) steps. ------------------------ Further applications to binary trees, along ``Euler tour'': Traverse each edge twice (once in each direction), but visit each node three times: A-visit, from parent (or ...) B-visit, from left child (or ...) C-visit, from right child (or ...) Example--calculate all depths: Calculate net depth along an Euler tour, as prefix sums of appropriate 1's, -1's, and 0's. ------------------------ Apparent CR advantages (i.e., CREW over EREW): 1. Everyone find info from his tree's root 2. Broadcast by a leader (even if only he knows he leads) (30.2-1) Intuitive reason: News spread can only double on each step. (Not rigorous? Learn also from absence of a write?) Apparent (common) CW advantages (i.e., common-CRCW over CREW): 1. Maximum entry in an array 2. OR of array of Boolean values ------------------------ Look at some of the exercises now ------------------------ Let's look at a lower-bound proof for OR. Note: Since the inputs are just bits, we cannot argue that some of them go ``unseen''! (This is only cited, not actually given, in CLR.)