Presentation is loading. Please wait.

Presentation is loading. Please wait.

List Ranking Moon Jung Chung

Similar presentations


Presentation on theme: "List Ranking Moon Jung Chung"— Presentation transcript:

1 List Ranking Moon Jung Chung
CSE838 Lecture notes copy right: Moon Jung Chung 5/16/2019

2 Pointer Jumping Review
How to compute a prefix on a linked list? If NEXT[i] != NILL then X[i] <- X[i] + X[NEXT[i]] NEXT[i] <- NEXT[NEXT[i]] 1 2 3 4 5 6 7 10 14 18 22 13 7 3 5 9 11 28 27 25 work O(nlogn) is not optimal CSE838 Lecture notes copy right: Moon Jung Chung 5/16/2019

3 Pointer Jumping Review
How to compute a prefix on a linked list? 1 2 3 4 5 6 7 3 2 7 4 11 6 7 10 2 7 4 18 6 7 28 27 25 22 18 13 7 A node does not not jump if it is jumped over. How to know to jump or not? CSE838 Lecture notes copy right: Moon Jung Chung 5/16/2019

4 Random Pointer Jumping
female male pointer jump only if female-male 1 2 3 4 5 6 7 8 1 3 5 8 2 4 6 7 A->B->C is jumped to A->C. B is jumped over. No jump crossing. i.e., A-> B->C and B->C->D simultaneously Once a node is jumped over, the node becomes inactive. In reconstruction phase, process are activated in reverse order. CSE838 Lecture notes copy right: Moon Jung Chung 5/16/2019

5 Random list ranking algorithm
rank[i] = 1, active[i] = true, t=1 in parallel while next[head] != nil { if (active[i] and next[i]!= nil) { sex[i] = random {M,F} if sex[i] = F and sex[next[i]] = M { time[next[i]] = t active[next[i]] = false rank[i] = rank[i] + rank[next[i]] next[i] = next[next[i]] } t++ for k=t down to 1 {if (time[i] = t and next[i] != nil) CSE838 Lecture notes copy right: Moon Jung Chung 5/16/2019

6 complexity of easy random list ranking
Prob that a cell is not jumped over: 3/4 Probability that a cell is not jumped over after k-iteration: (3/4)k Pi: cell is not not jumped over after k rounds. At least one cell is not jumped over after k rounds: = P1  P2 ...  Pn  P1 + P Pn = 1/n(c-1) if we choose (3/4)k < 1/nc So, for (3/4)k < 1/nc <=> k = clog 4/3n, the error that it goes more than clog 4/3n rounds becomes 0. CSE838 Lecture notes copy right: Moon Jung Chung 5/16/2019

7 Random ranking algorithm with O(n/logn) PEs, O(logn) time
Shared memory model each processor handles logn cell as a queue processor only look at the top of the queue jump over top i only if j=prev[i] is top. Then nex[j] = next[i] and remove top from the queue Still has memory imbalance Each PE can splice out: Slice_out(i) prev[next[i]] = prev[i] and next[ptev[i]] = next[i] rank[prev[i]] = rank[prev[i]]+ rank[i] if next[i] != nil then prev[next[i]] = prev[i] CSE838 Lecture notes copy right: Moon Jung Chung 5/16/2019

8 CSE838 Lecture notes copy right: Moon Jung Chung
Algorithm Initially: rank[i,k] = 1, sex[i,k] = F top[i] = Q[i].1 // Queue of PE i’s 1st element. sex[nil] = M t=1 while next[head] != nil { if position of top[i]  logn { sex[top[i]] = random{M,F} if (sex[prev[top[i]]] = F and sex[top[i]] = M { spliceout(top[i]) position of top[i] points next in the queue of PE i splicetime[top[i]] = t } t++; Observation: Prob. that a particular queue is not empty after 16logn rounds is < 1/n. Theorem: Expected running time is O(logn) CSE838 Lecture notes copy right: Moon Jung Chung 5/16/2019

9 Optimal Deterministic List Ranking Algorithm
How to pick 1/4 PEs with guarantee? k-Ruling set: G=(V,E) be the directed graph representation of a linked list L with vertices v1,...,vn. A subset S of V is a ruling set if 1. No two vertices in S are adjacent. 2. For each vertex vi in V, there is a directed path from some vertex in S to vi with length at most k. S: head of each segment of linked list, k is the length from the ruler. If we have a k-ruling set, every time we can select rulers (n/k elements) without conflict. Observation: k-coloring of a linked list can be converted into k-ruling set. How to find k-ruling set? CSE838 Lecture notes copy right: Moon Jung Chung 5/16/2019

10 Deterministic Coin Tossing and k-Coloring
CSE838 Lecture notes copy right: Moon Jung Chung 5/16/2019

11 List Ranking and Ruling Set
N/logN PEs Each PE has logN data Each PE has N/logN data 1. Find a 6 ruling set 2. Apply splice operation for ruling set Each iteration: c(N/logN) = top element be eliminated C(N/logN) k = N , k = O(logN) Complexity: O(logN* (log*N)logN) CSE838 Lecture notes copy right: Moon Jung Chung 5/16/2019

12 New Divide and Conquer Approach
List-Ranking (A, m) 1. If m < n/logn, apply list ranking with each PE one node 2. Find Ruling Set 3. Reduce list to A’ 4. List-Ranking(A’, m’) Depth of recursion O(loglogN) Complexity logn * loglogN CSE838 Lecture notes copy right: Moon Jung Chung 5/16/2019


Download ppt "List Ranking Moon Jung Chung"

Similar presentations


Ads by Google