{3, -1, 5, 6, 2}
p1 = 3, p2 = -1, p3 = 5, p4 = 6, p5 = 2
Splitter -> 3 (p1)
B's - {0,1,0,0,1}
Rank of selecting the splitter S - {0, 1, 1, 1, 2}
p1 = 2 p2 = -1 p3 = 3 p4 = 6 p5 = 5
{2, -1}
p1 = 2 p2 = -1
Splitter -> 2 (p1)
B's - {0,1}
Rank of selecting the splitter - s = {0, 1}
p1 = -1 p2 = 2
{6, 5}
p4 = 6 p5 = 5
Splitter -> 6 (p5)
B's - {0,1}
Rank of selecting the splitter - s= {0, 1}
Each processer sets bit in B if their element is less than the splitter B = [1,1,1,0,1] S = [1,2,3,3,4] Check: n/4 <= 4 <= 3n/4 fails
Each processer sets bit in B if their element is less than the splitter B = [1,1,0,0,1] S = [1,2,2,2,3] Check: n/4 <= 3 <= 3n/4 passes We then map any element where B[i] == 1 to C[s[i]] C = [3,-1,2,5,6]
1. Randomly selecting one of the processors as splitter: Processor at last index of array (value= 2)
2. Value of B: {0,1,0,0,1}, S = 2
3. Condition: (5)/(4) < S < (3)*(5)/(4) is True
4. C = { -1, 2, 3, 5, 6} : Sorted
| P1 | P2 | P3 |
| -1 | 2 | 3,5,6 |
| P1 | P2 | P3 | P4 | P5 |
| -1 | 2 | 3 | 5 | 6 |
items : {3, -1, 5, 6, 2}
n = 5
random no : 3
p1: 3 = [(n)/(4),(3*n)/(4)] [(3)/(4),(9)/(4)] = since
need to restart again
randome no picked = -1
p1 = 3 , p2 = -1 , p3 = 5 , p4 = 6 , p5 = 2
B = {1, 1, 0, 0, 1}
A = [3,-1,5,6,2] Splitter = 5 ; randomly choosen B = [1,1,1,0,1] ; 0 if value is greater than splitter, one otherwise S = [1,2,3,3,4] Rank of splitter = 4 Not in range [5/4, 3*5/4] ; So repeat
Splitter = 2 B = [0,1,0,0,1] S = [0,1,1,1,2] Rank of splitter = 2 In Range [5/4, 3*5/4] C = [-1,2,3,5,6]; For all B[i] = 1; place value A[i] in C[S[i]] Sorted