From: Khalid Rumman on
Hi
I'm Beginner at MATLAB and i need to use this algorithm that implements the CRCW PRAM parallel quicksort in my project.
The binary tree construction procedure for the CRCW PRAM parallel quicksort formulation.
1. procedure BUILD TREE (A[1...n])
2. begin
3. for each process i do
4. begin
5. root := i;
6. parenti := root;
7. leftchild[i] := rightchild[i] := n + 1;
8. end for
9. repeat for each process i r oot do
10. begin
11. if (A[i] < A[parenti]) or
(A[i]= A[parenti] and i <parenti) then
12. begin
13. leftchild[parenti] :=i ;
14. if i = leftchild[parenti] then exit
15. else parenti := leftchild[parenti];
16. end for
17. else
18. begin
19. rightchild[parenti] :=i;
20. if i = rightchild[parenti] then exit
21. else parenti := rightchild[parenti];
22. end else
23. end repeat
24. end BUILD_TREE
After building the binary tree, the algorithm determines the position of each element in the sorted array. It traverses the tree and keeps a count of the number of elements in the left and right subtrees of any element. Finally, each element is placed in its proper position in time Q(1), and the array is sorted.

I'll be grateful if any one can help with this.
thanks

From: Walter Roberson on
Khalid Rumman wrote:

> 1. procedure BUILD TREE (A[1...n]) 2. begin 3. for each process
> i do 4. begin 5. root := i; 6. parenti := root;
> 7. leftchild[i] := rightchild[i] := n + 1; 8. end for
> 9. repeat for each process i r oot do 10. begin 11. if
> (A[i] < A[parenti]) or (A[i]= A[parenti] and i <parenti)
> then 12. begin 13. leftchild[parenti] :=i ;
> 14. if i = leftchild[parenti] then exit 15. else
> parenti := leftchild[parenti]; 16. end for 17. else
> 18. begin 19. rightchild[parenti] :=i; 20. if
> i = rightchild[parenti] then exit 21. else parenti :=
> rightchild[parenti]; 22. end else 23. end repeat 24. end
> BUILD_TREE

Line 16 _appears_ to be incorrect. It is an 'end for', but the only enclosing
repetition loop is the 'repeat' for which there is an explicit 'end repeat'.
From: Khalid Rumman on
Walter Roberson wrote
> Line 16 _appears_ to be incorrect. It is an 'end for', but the only enclosing
> repetition loop is the 'repeat' for which there is an explicit 'end repeat'.

Thanks for your note, the corrections can be found at :
http://users.atw.hu/parallelcomp/ch09lev1sec4.html