LYCOS RETRIEVER
Merge Sort
built 169 days ago
The strategy behind Merge Sort is to change the problem of sorting into the problem of merging two sorted sub-lists into one. If the two halves of the array were sorted, then merging them carefully could complete the sort of the entire list.
Source:
These functions stably sort an array using a merge sorting algorithm. The algorithm requires an auxiliary array of the same size, identified by the argument b2. They return a pointer to either (1) the original array or (2) the auxiliary array, depending on which one contains the final result of the sort.
Source:
This class implements a merge sort using TupleSpace. It is an example of how to use the com.ibm.tspaces package. It generates a number of random integers and then uses TupleSpace as a communication medium to coordinate the activities of a number of threads that perform the actual sorting/merging. This version of MergeSort2 makes use of the Merger class that implements the Eval interface so that Worker threads on other systems can do the work.
Source:
Paul E. Black, "merge sort", in Dictionary of Algorithms and Data Structures [online], Paul E. Black, ed., U.S. National Institute of Standards and Technology. 14 May 2007. (accessed TODAY) Available from: http://www.nist.gov/dads/HTML/mergesort.html
Source:
'What is a merge sort? That's a difficult question to 'demonstrate, but not one to answer ' ' basically, the MergeSort function takes a ' group of elements, and you ' split the group in ' half or as near to half as possible. ' ' Then it runs MergeSort on each half. ' If there is two or fewer elements in the array when called, ' ... mergesort compares the elements, sorts them and ' returns them to the previous calling MergeSort. We are said, ' at that point to have descended the tree as far as we can. ' then, the elements are merged together in order by the Merge ' function.and on back up the chain until the whole thing is in ' order ' ' It's very quick. It's much quicker than the simple BubbleSort ' routine at the bottom that sorts the two element arrays for ' the Merge function ' ' Bubble sort's maximum iterations are x*x ' Merge sort's maximum iterations are x log x 'EXAMPLE USAGE 'Dim s(4) As String 'Dim s2() As String 'Dim s3() As String 's(0) = "XX" 's(1) = "A" 's(2) = "RR" 's(3) = "LL" 's(4) = "AABB" 's2 = MergeSort(s) 's3 = BubbleSort(s) Public Function MergeSort(Strings() As String) As String() Dim s As Long, i As Long, n() As String, m() As String Dim u As Long, l As Long, j As Long, x() As String ' we don't sort 1 element!
Source:
Merge sort is good for data that's too big to have in memory at once, because its pattern of storage access is very regular. It ... uses even fewer comparisons than heapsort, and is especially suited for data stored as linked lists.
Source: