<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE article  PUBLIC "-//NLM//DTD Journal Publishing DTD v3.0 20080202//EN" "http://dtd.nlm.nih.gov/publishing/3.0/journalpublishing3.dtd"><article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="3.0" xml:lang="en" article-type="research article"><front><journal-meta><journal-id journal-id-type="publisher-id">OJAppS</journal-id><journal-title-group><journal-title>Open Journal of Applied Sciences</journal-title></journal-title-group><issn pub-type="epub">2165-3917</issn><publisher><publisher-name>Scientific Research Publishing</publisher-name></publisher></journal-meta><article-meta><article-id pub-id-type="doi">10.4236/ojapps.2019.95034</article-id><article-id pub-id-type="publisher-id">OJAppS-92741</article-id><article-categories><subj-group subj-group-type="heading"><subject>Articles</subject></subj-group><subj-group subj-group-type="Discipline-v2"><subject>Biomedical&amp;Life Sciences</subject><subject> Chemistry&amp;Materials Science</subject><subject> Computer Science&amp;Communications</subject><subject> Engineering</subject><subject> Physics&amp;Mathematics</subject></subj-group></article-categories><title-group><article-title>
 
 
  An NC Algorithm for Sorting Real Numbers in &lt;em&gt;O&lt;/em&gt;(nlogn/√&lt;span style=&quot;margin-left:-4px;margin-right:2px;border-top:2px solid black&quot;&gt;loglogn&lt;/span&gt;) Operations
 
</article-title></title-group><contrib-group><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Yijie</surname><given-names>Han</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref><xref ref-type="corresp" rid="cor1"><sup>*</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Sneha</surname><given-names>Mishra</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref><xref ref-type="corresp" rid="cor1"><sup>*</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Md</surname><given-names>Usman Gani Syed</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref><xref ref-type="corresp" rid="cor1"><sup>*</sup></xref></contrib></contrib-group><aff id="aff1"><addr-line>School of Computing and Engineering, University of Missouri at Kansas City, Kansas City, MO, USA</addr-line></aff><pub-date pub-type="epub"><day>28</day><month>04</month><year>2019</year></pub-date><volume>09</volume><issue>05</issue><fpage>403</fpage><lpage>408</lpage><history><date date-type="received"><day>8,</day>	<month>April</month>	<year>2019</year></date><date date-type="rev-recd"><day>27,</day>	<month>May</month>	<year>2019</year>	</date><date date-type="accepted"><day>30,</day>	<month>May</month>	<year>2019</year></date></history><permissions><copyright-statement>&#169; Copyright  2014 by authors and Scientific Research Publishing Inc. </copyright-statement><copyright-year>2014</copyright-year><license><license-p>This work is licensed under the Creative Commons Attribution International License (CC BY). http://creativecommons.org/licenses/by/4.0/</license-p></license></permissions><abstract><p><html>
 <head></head>
 
  We apply the recent important result of serial sorting of n real numbers in
   <img src="Edit_2e4e7a7f-6962-47f9-a336-90f91c47eb1b.bmp" alt="" /> 
  time to the design of a parallel algorithm for sorting real numbers 
  in <img src="Edit_516d201b-e3e7-4543-8e33-9c714b67a143.bmp" alt="" /> 
  time and <img src="Edit_6a3a573d-b7d8-4189-b687-050ada0f0976.bmp" alt="" />
   
  operations. This is the first 
  NC algorithm known to take <img src="Edit_ab343827-c3bc-44f2-bea7-69040c343241.bmp" alt="" />
  operations for sorting real numbers. 
   
   √loglogn 
  
 
</html></p></abstract><kwd-group><kwd>Parallel Algorithms</kwd><kwd> Sorting</kwd><kwd> Sort Real Numbers</kwd><kwd> Complexity</kwd></kwd-group></article-meta></front><body><sec id="s1"><title>1. Introduction</title><p>It is known widely that serial comparison sorting takes θ ( n log n ) time for sorting n numbers [<xref ref-type="bibr" rid="scirp.92741-ref1">1</xref>] . Although integer sorting can outperform the Ω ( n log n ) lower bound for sorting n integers [<xref ref-type="bibr" rid="scirp.92741-ref2">2</xref>] [<xref ref-type="bibr" rid="scirp.92741-ref3">3</xref>], these algorithms generally do not apply to the problem of sorting real numbers. It has been known that n integers can be sorted in O ( n log log n ) time and linear space [<xref ref-type="bibr" rid="scirp.92741-ref2">2</xref>] [<xref ref-type="bibr" rid="scirp.92741-ref3">3</xref>] . The O ( n log n ) time bound remains for sorting real numbers ever since. Only very recently Han showed that real numbers can be converted to integers for the sorting purpose in O ( n log n ) time [<xref ref-type="bibr" rid="scirp.92741-ref4">4</xref>], thus enabling the serial sorting of real numbers in O ( n log n ) time.</p><p>Parallel sorting algorithms for sorting real numbers run on the PRAM (Parallel Random Access Machine) model are known [<xref ref-type="bibr" rid="scirp.92741-ref5">5</xref>] [<xref ref-type="bibr" rid="scirp.92741-ref6">6</xref>] . The AKS sorting network [<xref ref-type="bibr" rid="scirp.92741-ref5">5</xref>] can be transformed into an EREW (Exclusive Read Exclusive Write) PRAM algorithm with O ( log n ) time and O ( n log n ) operations. Cole’s parallel merge sort [<xref ref-type="bibr" rid="scirp.92741-ref6">6</xref>] sorts n numbers in O ( log n ) time using n processors on the EREW PRAM. On the CRCW (Concurrent Read Concurrent Write) PRAM Cole showed [<xref ref-type="bibr" rid="scirp.92741-ref7">7</xref>] that his parallel merge sort can run in O ( log n / log log ( 2 p / n ) ) time using p processors. Also see [<xref ref-type="bibr" rid="scirp.92741-ref7">7</xref>] .</p><p>There are also parallel algorithms for integer sorting [<xref ref-type="bibr" rid="scirp.92741-ref8">8</xref>] [<xref ref-type="bibr" rid="scirp.92741-ref9">9</xref>] [<xref ref-type="bibr" rid="scirp.92741-ref10">10</xref>] [<xref ref-type="bibr" rid="scirp.92741-ref11">11</xref>] . In the case of integer sorting, the operation bound can be improved to below O ( n log n ) . In particular, [<xref ref-type="bibr" rid="scirp.92741-ref10">10</xref>] presents a CRCW PRAM integer sorting algorithm with O ( log n ) time and O ( n log log n ) operations and [<xref ref-type="bibr" rid="scirp.92741-ref11">11</xref>] presents an EREW PRAM integer sorting algorithm with O ( log n ) time and O ( n log n ) operations.</p><p>For sorting real numbers, the previous best serial algorithm sorts in O ( n log n ) time. It was also known that for comparison sorting, Ω ( n log n ) is the tight lower bound. Thus if we use comparison sorting to sort real numbers, then in serial algorithms, we cannot avoid the Ω ( n log n ) time bound and in parallel algorithms, we cannot avoid the Ω ( n log n ) operation bound. In the past, no other sorting methods are known to sort real number in less than O ( n log n ) time and comparison sorting remained the norm for sorting real numbers.</p><p>However, the situation is recently changed completely as Han found a way to convert real numbers to integers for sorting purpose and he showed that real numbers can be sorted in O ( n log n ) time [<xref ref-type="bibr" rid="scirp.92741-ref4">4</xref>] . This result enables us to move further to improve the operation bound of parallel algorithms for sorting real numbers to below O ( n log n ) , as in the past, all parallel algorithms for sorting real numbers have an operation bound at least O ( n log n ) .</p><p>In this paper, we will apply the O ( n log n ) time serial real number sorting algorithm [<xref ref-type="bibr" rid="scirp.92741-ref4">4</xref>] to the design of an NC algorithm with O ( log 1 + ε n ) time and</p><p>O ( n log n log log n ) operations on the CREW (Concurrent Read Exclusive Write)</p><p>PRAM. NC stands for Nick’s Class [<xref ref-type="bibr" rid="scirp.92741-ref12">12</xref>] . NC algorithms are parallel algorithms with polylog time and polynomial operations. Algorithm in [<xref ref-type="bibr" rid="scirp.92741-ref4">4</xref>] is an inherently serial algorithm without much parallelism within it. Here, we use it in the design</p><p>of an NC algorithm with O ( log 1 + ε n ) time and O ( n log n log log n ) operations. This is the first NC algorithm for sorting real numbers with o ( n log n ) operations.</p><p>The computation model used for designing our algorithm is the CREW PRAM. On this model, in one step, any processor can read/write any memory cell. Concurrent read of one memory cell by multiple processors in one step is allowed and concurrent write of one memory cell by multiple processors in one step is prohibited. Parallel algorithms can be measured with their time complexity and the number of processors used. They can also be measured with time complexity and operation complexity which is the time processor product. The operation complexity (T<sub>p</sub>p, with T<sub>p</sub> time using p processors) of a parallel algorithm is often compared with the time T<sub>1</sub> of the best serial algorithm. In general, T p p ≥ T 1 . When T p p = T 1 , the parallel algorithm is said to be an operation optimal algorithm.</p><p>The main contribution of this paper is the demonstration of the existence of an NC parallel algorithm with o ( n log n ) operations for sorting real numbers. All previous parallel algorithms for sorting real numbers have at least O ( n log n ) operations. The algorithm presented in this paper is derived from Han’s O ( n log n ) time serial algorithm [<xref ref-type="bibr" rid="scirp.92741-ref4">4</xref>] for sorting real numbers by applying parallel algorithm design techniques. These parallel algorithm design techniques are specially tuned for the derivation of our parallel algorithm.</p><p>The remaining part of this paper is organized as follows. In Section 2 we present our NC algorithm for sorting real numbers with O ( log 1 + ε n ) time and</p><p>O ( n log n log log n ) operations. In Section 3, we present a running example of our algorithm and conclude our paper with the Main Theorem.</p></sec><sec id="s2"><title>2. The Algorithm</title><p>Consider an algorithm for sorting n real numbers. Suppose each of the n/m lists with m real numbers in each list has already been sorted, we are to merge these n/m lists into one sorted list. We will do k-way merge in each pass to merge every k-lists into 1 sorted list and there are log ( n / m ) / log k passes to have all n/m lists merged into 1 sorted list.</p><p>For simplicity, let us break down n elements into lists with m elements in each list. We can do parallel sort on the individual list of m elements recursively. Now we pick every k-lists and have them merged together.</p><p>The k-way merging of sorted lists L 0 , L 1 , ⋯ , L k − 1 is done as follows. For each sorted list of m real numbers we pick every k<sup>2</sup>-th real number, i.e. we pick the 0th real number, the k<sup>2</sup>-th real number, the 2k<sup>2</sup>-th real number, the 3k<sup>2</sup>-th real number, and so on. Thus from each list L<sub>i</sub> we picked m/k<sup>2</sup> real numbers and these m/k<sup>2</sup> real numbers form a sorted list L ′ i . and from these k lists we picked m/k real numbers they form sorted lists L ′ 0 , L ′ 1 , ⋯ , L ′ k − 1 . We merge L ′ 0 , L ′ 1 , ⋯ , L ′ k − 1 into one sorted list L' using Valiant’s merging algorithm [<xref ref-type="bibr" rid="scirp.92741-ref13">13</xref>] (its improved version is given by Kruskal in [<xref ref-type="bibr" rid="scirp.92741-ref14">14</xref>] with time complexity of O ( log log m ) and linear operations for merging two sorted lists of m elements each) in logk passes and O ( log log m ) time and O ( m / k ) operations in each pass. Thus the total time for merging L ′ 0 , L ′ 1 , ⋯ , L ′ k − 1 is O ( log k log log m ) and the total operation is O ( m log k / k ) .</p><p>Now for each real number r in L ′ i and for any L ′ j , r knows the largest real number s in L ′ j that is smaller than r and smallest real number l in L ′ j that is larger than r. s and l are actually neighbors in L ′ j . There are k<sup>2</sup> elements between s and l in L<sub>j</sub>. r then uses binary search in O ( log k ) time to find the largest real number among these k<sup>2</sup> real numbers that is smaller than r and the smallest real number that is larger than r. That is, r finds the exact insertion point of r in L<sub>j</sub>. Because there are k-lists and there are m/k real numbers in L' thus the time for this binary search is <inline-formula><inline-graphic xlink:href="/html.scirp.org/file/10-2310973x60.png" xlink:type="simple"/></inline-formula> and the operation is<inline-formula><inline-graphic xlink:href="/html.scirp.org/file/10-2310973x61.png" xlink:type="simple"/></inline-formula>. The operation for all lists is O ( n log k / k ) because there are n/m lists and every k-lists are merged in the k-way merge, we picked n/k<sup>2</sup> real numbers and every one of them has to use k processors to check k-lists in the k-way merging. Because r is arbitrary picked and thus we know that every real number in L' knows its insertion point in every L<sub>j</sub>. Let the real numbers in sorted order in L' be r 0 , r 1 , ⋯ , r m / k − 1 . To merge L 0 , L 1 , ⋯ , L k − 1 we need now to merge or sort all real numbers between the insertion points of r<sub>i</sub> and r<sub>i</sub><sub>+1</sub> in L 0 , L 1 , ⋯ , L k − 1 . There are no more than k<sup>2</sup> real numbers in L<sub>j</sub> between the insertion points of r<sub>i</sub> and r<sub>i</sub><sub>+1</sub> and therefore the total number R ( i , i + 1 ) of real numbers (call them a block) in L 0 , L 1 , ⋯ , L k − 1 between the insertion points of r<sub>i</sub> and r<sub>i</sub><sub>+1</sub> is no more than k<sup>3</sup> (i.e. R ( i , i + 1 ) ≤ k 3 ). When R ( i , i + 1 ) &lt; k 3 we will combine multiple blocks together to reach k<sup>3</sup> real numbers. We use the O ( n log n ) serial sorting algorithm to sort them in O ( k 3 log k ) time. This represents O ( k 3 log k ) time and O ( n log k ) operations in our parallel algorithm.</p><p>Thus the time for each stage is O ( k 3 log k ) and the operation for each stage is O ( n log k ) . When we start with m as a constant then there are log n / log k</p><p>stages and therefore the time of our algorithm is O ( k 3 log n log k ) and the operation is O ( n log n log k ) .</p><p>Pick k = log ε n , we get O ( log 1 + ε n ) time and O ( n log n log log n ) operations.</p></sec><sec id="s3"><title>3. Procedure</title><p>Step 1: Let’s say we have “m” sorted elements in each list, and we have a total of “n” elements to sort (<xref ref-type="fig" rid="fig1">Figure 1</xref>).</p><p>This implies that we have “n/m” lists to sort. To sort these blocks, we will apply k-way merging.</p><p>Step 2: Each stage of k-way merging is to merge every k sorted lists into 1 sorted list. This is repeatedly until all n/m lists are merged into one list (<xref ref-type="fig" rid="fig2">Figure 2</xref>).</p><p>Step 3: To merge k lists into 1 list, we need to pick the “0-th”, “k<sup>2</sup>-th”, “2k<sup>2</sup>-th”, “3k<sup>2</sup>-th”, … real numbers in each list L<sub>i</sub> to form a new list L ′ i of m/k<sup>2</sup> elements. This is shown as <xref ref-type="fig" rid="fig3">Figure 3</xref>.</p><p>Step 4: We merge L ′ 0 , L ′ 1 , ⋯ , L ′ k − 1 into one sorted list L'. The elements of this new formed list L' then use binary search to find their exact insertion point in</p><p>L 0 , L 1 , ⋯ , L k − 1 . These insertion points then partition L 0 , L 1 , ⋯ , L k − 1 into m/k blocks with each block containing no more than k<sup>3</sup> real numbers.</p><p>Step 5: When every one of these m/k blocks are sorted, we effectively merged L 0 , L 1 , ⋯ , L k − 1 into one sorted list L.</p><p>Main Theorem: n real numbers can be sorted in O ( log 1 + ε n ) time and O ( n log n log log n ) operations on the CREW PRAM.</p><p>Proof: The algorithm and its time complexity analysis are presented in Section 2. An example of the running of the algorithm is presented in Section 3. □</p></sec><sec id="s4"><title>Conflicts of Interest</title><p>The authors declare no conflicts of interest regarding the publication of this paper.</p></sec><sec id="s5"><title>Cite this paper</title><p>Han, Y.J., Mishra, S. and Syed, M.U.G. (2019) An NC Algorithm for Sorting Real Numbers in Operations. Open Journal of Applied Sciences, 9, 403-408. https://doi.org/10.4236/ojapps.2019.95034</p></sec></body><back><ref-list><title>References</title><ref id="scirp.92741-ref1"><label>1</label><mixed-citation publication-type="other" xlink:type="simple">Corman, T.H., Leiserson, C.E., Rivest, R.L. and Stein, C. (2009) Introduction to Algorithms. Third Edition, The MIT Press.</mixed-citation></ref><ref id="scirp.92741-ref2"><label>2</label><mixed-citation publication-type="other" xlink:type="simple">Han, Y. (2015) A Linear Time Algorithm for Ordered Partition. International Workshop on Frontiers in Algorithmics (FAW'15), LNCS, 9130, 89-103. 
https://doi.org/10.1007/978-3-319-19647-3_9</mixed-citation></ref><ref id="scirp.92741-ref3"><label>3</label><mixed-citation publication-type="other" xlink:type="simple">Han, Y. (2004) Deterministic Sorting in O(nloglogn) Time and Linear Space. Journal of Algorithms, 50, 96-105. https://doi.org/10.1016/j.jalgor.2003.09.001</mixed-citation></ref><ref id="scirp.92741-ref4"><label>4</label><mixed-citation publication-type="other" xlink:type="simple">Han, Y. (2017) Sort Real Numbers in   Time and Linear Space. In arXiv.org with paper id 1801.00776.</mixed-citation></ref><ref id="scirp.92741-ref5"><label>5</label><mixed-citation publication-type="other" xlink:type="simple">Ajtai, A., Komlós, J. and Szemerédi, E. (1983) An O(nlogn) Sorting Network. Proceedings of the Fifteenth Annual ACM Symposium on Theory of Computing, Boston, MA, 11-13 May 1983, 1-9. https://doi.org/10.1145/800061.808726</mixed-citation></ref><ref id="scirp.92741-ref6"><label>6</label><mixed-citation publication-type="other" xlink:type="simple">Cole, R. (1988) Parallel Merge Sort. SIAM Journal on Computing, 17, 770-785.  
https://doi.org/10.1137/0217049</mixed-citation></ref><ref id="scirp.92741-ref7"><label>7</label><mixed-citation publication-type="other" xlink:type="simple">Saxena, S., Chandra, P., Bhatt, P. and Prasad, V.C. (1994) On Parallel Prefix Computation. Parallel Processing Letters, 4, 429-436.  
https://doi.org/10.1142/S0129626494000399</mixed-citation></ref><ref id="scirp.92741-ref8"><label>8</label><mixed-citation publication-type="other" xlink:type="simple">Bhatt, P.C.P., Diks, K., Hagerup, T., Prasad, V.C., Radzik, T. and Saxena, S. (1991) Improved Deterministic Parallel Integer Sorting. Information and Computation, 94, 29-47. https://doi.org/10.1016/0890-5401(91)90031-V</mixed-citation></ref><ref id="scirp.92741-ref9"><label>9</label><mixed-citation publication-type="other" xlink:type="simple">Hagerup, T. (1987) Towards Optimal Parallel Bucket Sorting. Information and Computation, 73, 39-51. https://doi.org/10.1016/0890-5401(87)90062-9</mixed-citation></ref><ref id="scirp.92741-ref10"><label>10</label><mixed-citation publication-type="other" xlink:type="simple">Han, Y. and Shen, X. (1995) Conservative Algorithms for Parallel and Sequential Integer Sorting. International Computing and Combinatorics Conference, Lecture Notes in Computer Science, 959, 324-333. https://doi.org/10.1007/BFb0030847</mixed-citation></ref><ref id="scirp.92741-ref11"><label>11</label><mixed-citation publication-type="other" xlink:type="simple">Han, Y. and Shen, X. (2002) Parallel Integer Sorting Is More Efficient than Parallel Comparison Sorting on Exclusive Write PRAMs. Tenth Annual ACM-SIAM Symposium on Discrete Algorithms (SODA’99), Baltimore, Maryland, January 1999, 419-428. https://doi.org/10.1137/S0097539799352449</mixed-citation></ref><ref id="scirp.92741-ref12"><label>12</label><mixed-citation publication-type="journal" xlink:type="simple"><name name-style="western"><surname>Cook</surname><given-names> S.A. </given-names></name>,<etal>et al</etal>. (<year>1981</year>)<article-title>Towards a Complexity Theory of Synchronous Parallel Computation</article-title><source> L’Enseignement Mathématique</source><volume> 27</volume>,<fpage> 99</fpage>-<lpage>124</lpage>.<pub-id pub-id-type="doi"></pub-id></mixed-citation></ref><ref id="scirp.92741-ref13"><label>13</label><mixed-citation publication-type="other" xlink:type="simple">Valiant, L.G. (1975) Parallelism in Comparison Problems. SIAM Journal on Computing, 4, 348-355. https://doi.org/10.1137/0204030</mixed-citation></ref><ref id="scirp.92741-ref14"><label>14</label><mixed-citation publication-type="other" xlink:type="simple">Kruskal, C.P. (1983) Searching, Merging, and Sorting in Parallel Computation. IEEE Transactions on Computers, C-32, 942-946.  
https://doi.org/10.1109/TC.1983.1676138</mixed-citation></ref></ref-list></back></article>