an optimal parallel algorithm for the multiselection problem

5
Short communication An optimal parallel algorithm for the multiselection problem Muhammad H. Alsuwaiyel Department of Information and Computer Science, King Fahd University of Petroleum and Minerals, Dhahran 31261, Saudi Arabia Received 27 July 1998; received in revised form 3 November 1999; accepted 29 June 2000 Abstract Given a set S of n elements drawn from a linearly ordered set, and a set K fk 1 ; k 2 ; ... ; k r g of positive integers between 1 and n, the multiselection problem is to select the k i th smallest element for all values of i; 1 6 i 6 r. We present a simple optimal algorithm to solve this problem that runs in On log r time on the EREW PRAM with n 1 processors, 0 << 1. Ó 2001 Elsevier Science B.V. All rights reserved. Keywords: Algorithms; Parallel algorithms; Selection; Multiselection 1. Introduction Let S be a set of n elements drawn from a linearly ordered set, and let K fk 1 ; k 2 ; ... ; k r g be a set of positive integers between 1 and n, that is a set of ranks. The multiselection problem is to select the k i th smallest element for all values of i; 1 6 i 6 r. If r 1, then we have the classical selection problem. On the other hand, if r n, then the problem is tantamount to the problem of sorting. Recently, Shen [4] presented an optimal parallel for multiselection that runs in time On log r on the EREW PRAM with n 1 processors, 0 << 1. We will show that the multiselection problem can easily be solved using an adaptive algorithm that runs in On log r time on the EREW PRAM with n 1 processors, 0 << 1, by slightly modifying the adaptive parallel quicksort algorithm in [1,2]. The algorithm that will be presented can be thought of as a generalization of the paradigm given in [4]. Parallel Computing 27 2001) 861±865 www.elsevier.com/locate/parco E-mail address: [email protected] M.H. Alsuwaiyel). 0167-8191/01/$ - see front matter Ó 2001 Elsevier Science B.V. All rights reserved. PII: S 0 1 6 7 - 8 1 9 1 0 0 ) 0 0 0 9 5 - 8

Upload: muhammad-h-alsuwaiyel

Post on 02-Jul-2016

214 views

Category:

Documents


1 download

TRANSCRIPT

����� ���������

� � ���� ������� �������� ��� �������������� ������

�������� �� ���������

���������� �������� �� ������� �������� ���� ��� ���������� �������� �� ���������

������� �� !�� ��� � "��#��

������� �� ���� � !" ������� ������ ���� # $������� � " ���� ��� � ��� �%%%

��������

&�� � ��� � �� � ������� ���� ���� � ������ ������� ���' �� � ��� � � ���� ��� � � � � ����� ����� ������ ������ � �� �' ��� ������������� ������ � �� ������ ��� ���� ��������

������ ��� ��� ������ �� �� �� �� �� (� ����� � �� �� � ���� �������� �� ����� ���

������ ���� ��� )��� ��� �� ��� � ��� *�*( +��� ��� ���� ���������'

% � � � �� � �%%� *������ ����� ,�-� ��� ����� ���������

���$� �% ���������" +������� ���������" �������" �����������

� ���� ������

.�� � �� � ��� �� � ������� ���� ���� � ������ ������� ���' �� ���� � ���� ��� � � � � ��� �� � ��� �� ����� ������ ������ � �� �' ���� � � ��� �� ��/��0�� ������������� ������ � �� ������ ��� ���� �������� ������ ��� ��� ������ ���� �� �� �� 1� � � �' ��� �� ���� ��� �������� ������� ������� ) ��� ����� ���'� � � �' ��� ��� ������ � �������� �� ��� ������ �� ������ �������' ��� 234 ������� � � ���� ������� ��� ����������� ���� ��� ��� )��� ��� �� � ���*�*( +��� ��� ���� ���������' % � � � �� (� ��� ���� ���� ��� ����������� ������ �� ����� �� ������ ��� � ��� ��� �������� ���� ��� )��� ��� ����� � ��� *�*( +��� ��� ���� ���������' % � � � �' �� ������� ������ ������ ��� ������� 5��/���� �������� 2�'�4� 0�� �������� ���� ��� �� ��������� �� ������� �� �� � ������6��� �� ��� ������ ��� 234�

+������� 7�� ��� �� 8�%%�9 !:�;!:<

���������������=������= ����

&'���� � ����% �������>/�� �������� 8���� ���������9�

%�:�?!� �=%�=@ ? ��� ���� ������ � �%%� *������ ����� ,�-� ��� ����� ���������

+11A � % � : � ? ! � � 8 % % 9 % % % < ? !

B�� �� ��� ���������� �� ��� ����������� ������ �� ��� ����� ������' � ������� �� ��/ � � �������� ��� ��� ������ �� �� ���C�� �� ���� � ������ ���������� 1� ���� ��� ���� � ����� ���C���� �� ��� ������� 5��/���� ��������������� � � ���� �������� ��� ��� ����������� ������� .�� ������ �� � ������5����� ������� ��������� 0�� ���� ����� ������ ��� ����������� ������ ��� ��� ��� ��� (� ��� ������ ���� ��� ��� �� ��/� � � ���� ��� � � � � ��� � ������ ������ ������ 1� ��' ��� � �� �� ������ ��� ��� �� ����

���������' �� ��� ����� � ������ �� � �� ���� ��� ����� ��� (�� �������������� �� �������' �� ��� ����� � ������ �� � �� �� ��� ����� ��� (���������� ������ �� D�� �� ����' �� ��� ������ ���� ��� ������� � ���������

��������� ������� ������� �� � � �� �� �� ������ �� � � ��� ���� ������ ������ ��� ��#� ����

3� � �<� � ������:� ������ 8���9�� �� � � � � �����!� �� � � � � ����� � �� � ���� ��� � � � � �����

�%� �� � ��������� � �� �������� � �� � � � � �� � ����� ������� ���������� ������� ��������#� �� ��

�3� �� ��

��� ��� ������� �� �� � ���� ��' ��� ��� ��� ��E�� �� �������� ������� ���� ��� ���

�� �� ��� ����� ���� ��� �����������' �� ��� ���� � � ��� ��� ��� 0��' ������� � � �' �� ����� �� ���� �� ���� � ������� ��� ��� �� ���' ��������� ������ ��� �� ����� ���� ��� ����� � ��� ����� ����� �� ��� ������ 0�� ��������� ��� ��� �������� ���������� 2#4 ��� ����E� �� ��� � ������� 1�������� ���� ��� ����������� ������ � ��� ��� ��' �� ���� ��� �������� �������� � � �����

� ��� �������� ���������

1 ��� �����' �� ���� ���� ��� ����������� ������ �� �� ������ )��� ��� �� ��� � ��� *�*( +��� ��� ���� ���������' % � � � �' �� ������������� ��� ��� ��� ������� 5��/���� �������� 2�'�4� 0�� ���� ��� �������������� �������� 234' ���� �� ��� ���� �*.*70�*.*70� �������� �*.*70�*.*70 ��� ���)���� ��� � ���� ��������� � ��� *�*( +����

!:� �)*) "���$����� + �������� �������� , - ..�/ 0!�10!2

.�� 3 �� ��� ����� �� ��������� ���� ��� ����������� ��������' ������ � � �' ���� � ����� .�� 4 �� � � �� ������ ����� ����� ����� ������������ ��� �' ��� � � ���� !�� 0�� �������� ���/� �� �������� .�� � � ������D�� ������' �� ��� ��C� �% � % �� ���%� � ��� D���' �������� �*.*70�*.*70 C���� ��� ��� ��� �������

�� � ������� �� �� �� ���� ��/� ��� ���

� � � ���� �� �� �� ���0�� ��� ���� � ��� ������� �� 4 �������A ��� ��� � � � � ��' �����

�� � � � ���������� � � ���������� �� �� �� �' ��

�� � � � � �������������������' ��� ��� �� ��/� ��� � � ������� �� 4 ������� ������ � � � ���' �����

�� � �� � ��� ��� � � � ������ �� �� �� �' ��

�� � �� � ��� ��� � �� ���0�� �������� � ���' ���������� ������ ������� � ��� 4 ��� �������' �� �� �'����� ��� ����� �� ��������� ���� ���� �������� ���� � �� ������ �� ��� �6��� ��� ������ ��' ���' �����

0���' ��� ������� �� �� � � ������6��� �� ��� ������ ��� 234' ���� ���� ��� ��� �� ������� �� ��� ��� �� ��/� ��� ����� �� ��� ����� ����'���� ��� ����� �� 4 ����' �� 4 �� �� ���� ��� � ���� ���������� 0��������� � ��� ������

��������� ��*.*70��*.*70 �������� �� �� � ����

�� ��� � � �� � �#� �*.*70�*.*70 ��� ����3� ������ �����<� �� ���

:� ������ � �����!� � �% � ��� � � �� �� � �

�%� �*.*70�*.*70 ��� �������� ������ ��������� �� � � ���������� � � ��������#� �� ���������� � �� ��������� � �� � � � � ����� � ���3� � ����<� �� ���

�)*) "���$����� + �������� �������� , - ..�/ 0!�10!2 !:#

�:� �� � � � �������������� �� ���������� � �� ��������� � �� � � � � �� � ���!� ��� � � �� 4 � �� ��������

� � ��*.*70��*.*70 ������� ������%� �� ���

��� �� ��

1� � �� ���� �� ��� ���� �������� ��*.*70��*.*70 ���/� ���������� (� �� ����6� ����� ��� ��E��� *��� ���� �� �������� �*.*70�*.*70 ��� # �� �% ��/�� )���� ������� ��������� 234� ����� ���� ���� �*.*70�*.*70 ��� ������ �� � � �' �� ��' �� �E������� �� ���/� ����� ������� ������ 8�� �� �����9 ���������� �� ������' ���E������ ���� ��� ��� ������� ��CE �������� �� ��� ���� ��� ��� ����?����� ���������� 0��� �' ���� �������� ���/� � �� ������� �� ���/� ������������ ������ ���������� �� ������� 0�� � �������� �� � ��� ������� ��CE�� ��� ����� ����' ��� ��� ��5���� �� �������� ��� ��F� �)����� � ��� ������ � )������ ��� � � ������' �� � ���������� �� �E������ ������������ ������� ��� ���� �� ���� ��� �� )��� ���� D�� ���� �������� ����' �������� �� ��������� �

���� ������

�� ��

���

����' ��� ���� �� ��� ����� �� ������� �� ��� ����� �� ��������� �

������� � ���

�� ���� 234' ���� ���� �� �������� �*.*70�*.*70 ��/�� )���� ���� 1� ������� ���� ���������� ��� ��� �� �������� ��*.*70��*.*70 � ������� �� ��� ���������A

��� �� � ����� �� �)����� �)�� ��� ���0�� ������ �� ��� ��������� �

��� �� � )���� ���� �� � )��� ��� ����� ���� ��� ���� �� ��� �������� � )�� ��� ���

�������� �������

0�� ������ � �������� �� G� D��� H������ �� +�������� �� ������ ������� ������ �� ���� 0��/� �� ��� ������� �������� ��� ���� ��������������� ���� ��� �� � ���� ��� 5����� �� ��� �������� �� ��� � ���

����������

2�4 ��&� �/�' ) ���� ������� ��������� ��� ��� ��� ����E ����� �� ��� �����' 7�� ��� ##

8� !39 �;���

!:3 �)*) "���$����� + �������� �������� , - ..�/ 0!�10!2

2�4 ��&� �/�' 0�� B��� �� ������ �� +������� ���������' +����� ����' *������� 7�I�' $�' � ! �

2#4 ��.� D�����' 0��� � ����' ��C�� ��� ��E�� ������ ��� ��� � ������' ������ �� 7�� ����

�� ������ ������ 8� !�9 �: ;�!3�

234 �� ���' ) ���� ������� ����������� � *�*( +���' +������� 7�� ��� �# 8� �9 � !�;� ��

�)*) "���$����� + �������� �������� , - ..�/ 0!�10!2 !:<