Radix selection
| Class | Selection algorithm |
|---|---|
| Data structure | Array |
| Worst-case performance | , where is the number of keys, k is the number of values each key digit can store, and is the number of digits in the keys |
| Best-case performance |
In computer science, radix selection is a non-comparative selection algorithm, the selection analog of most-significant-digit (MSD) radix sort.[1] It enables selecting the k-th largest or smallest element of an unsorted array, or the top k elements which do not have to be in sorted order. While the simplest implementation of radix selection is as an in-place algorithm,[2] out-of-place parallel variants have also been developed for GPUs.[1][3][4][5][6][7]
In-place radix selection
In-place radix selection works on array elements one digit at a time, starting from the most significant digit (MSD). For instance, if an array of integers is being sorted, then the most significant digit of each array element is examined, counting how many 9's there are, 8's there are, 7's and so on, until 0's - for decimal number representation.
Once it is known how many elements have a 9 in the most significant digit, and 8 in the most significant digit and so on, the size of these bins is known, and the starting and ending array index for each of these bins can be computed. Since we are selecting a k-th element of the array, then it's know which bin the k-th element is in. This is the only bin that needs to be populated with its elements, in its target location. The rest of the array elements are not needed and can be ignored.
To gather all of the array elements that belong in the target bin (with the k-th element inside it) we start on the left side of the array, looking for an element that belongs in the target bin. Once we find one, we look inside the target bin for the first element that does not belong in this bin.[2] The element outside of the bin is then written into the bin, swapping with[2] (or, more efficiently, overwriting) the element that does not belong. This process continues until all array elements to the left of the bin have been moved inside the bin.
Now, the array to the right of the target bin is scanned for elements that belong inside the bin, until the end of the array has been reached. As elements that belong are found they are moved inside the bin by scanning inside the bin for elements that don't belong and pairing them up with elements outside the bin which belong.
Once the target bin has all of the elements that belong in it has been assembled, by moving elements from the outside of the bin that belong in the bin, the bin is processed in the same way recursively using the next most significant digit. This process continues until either the target bin (with the k-th index inside it) has a single element or all of the digits have been used and we have run out of digits. Then the k-th element of the array is returned.
See also
References
- ^ a b Alabi, Tolu; Blanchard, Jeffrey D.; Gordon, Bradley; Steinbach, Russel (July 2012). "Fast K-selection Algorithms for Graphics Processing Units" (PDF). ACM Journal of Experimental Algorithmics. 17. doi:10.1145/2133803.2345676. Archived from the original (PDF) on November 16, 2025.
- ^ a b c Elmasry, Amr; Mahmoud, Hosam (June 2011). "Analysis of swaps in radix selection". Advances in Applied Probability. 43 (2): 524–544. doi:10.1239/aap/1308662491.
- ^ Li, Yifei; Zhou, Bole; Zhang, Jiejing; Wei, Xuechao; Li, Yinghan; Chen, Yingda (2024). RadiK: Scalable and Optimized GPU-Parallel Radix Top-K Selection. Proceedings of the 38th ACM International Conference on Supercomputing. pp. 537–548. arXiv:2501.14336. doi:10.1145/3650200.3656596. ISBN 979-8-4007-0610-3.
- ^ Leckey, Kevin; Neininger, Ralph [in Tosk Albanian]; Sulzbach, Henning (1 February 2019). "Process convergence for the complexity of Radix Selection on Markov sources". Stochastic Processes and Their Applications. 129 (2): 507–538. arXiv:1605.02352v2. doi:10.1016/j.spa.2018.03.009.
- ^ Zhang, Christina (Jingrong); Wang, Yong (December 12, 2020). "Accelerating Top-K computation on GPU" (PDF). NVIDIA.
- ^ Zhang, Jingrong; Naruse, Akira; Li, Xipeng; Wang, Yong (12 November 2023). Parallel Top-K Algorithms on GPU: A Comprehensive Study and New Methods. SC '23: Proceedings of the International Conference for High Performance Computing, Networking, Storage and Analysis. pp. 1–13. doi:10.1145/3581784.3607062.
- ^ "Select-K — Matrix Ordering — raft documentation". NVIDIA.
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.