Special

Clearance Sale!

We've been publishing for over five years now and it's time to clear out our inventory of back issues, so we're slashing prices!

RBD Magazines

Check out this amazing clearance sale of all our past issues. Missing some issues? This is a great time to complete your RBD collection. Save up to 40% off the regular price of our printed back issue packages. These prices are only good until the end of the year May 2008 and supplies are limited, so place your order today.

Article Preview


Buy Now

Print:
PDF:

Algorithms

Sorting Arrays 2

Bring Order To Your Objects

Issue: 5.3 (March/April 2007)
Author: Charles Yeomans
Article Description: No description available.
Article Length (in bytes): 8,866
Starting Page Number: 40
RBD Number: 5315
Resource File(s): None
Related Web Link(s):

http://www.declareSub.com/

Known Limitations: None

Excerpt of article text...

In the last issue, we began our discussion of sorting with a review of sorting capabilities built into REALbasic, and discussed insertion sort, a fundamental and simple sorting algorithm. In this column we look at merge sort.

Merge

Recall that the idea of insertion sort is the following. Given a sorted list of elements, it is simple to scan the list to decide where to insert a new element in sorted position to create a new sorted list. This is a special case of a more general problem: given two sorted lists, merge them to create a single sorted list containing the elements of both lists.

There is an obvious and simple algorithm for doing this. We compare the first elements of the two lists, and move the lesser of the two to the new list. Once one list is empty, we then move the remaining elements to the new list. This is quick algorithm, requiring only a comparison for each element of the smaller list.

It is also easy to implement. Here we do a straightforward implementation; there are also others that are not so straightforward.

...End of Excerpt. Please purchase the magazine to read the full article.

Article copyrighted by REALbasic Developer magazine. All rights reserved.


 


|

 


Weblog Commenting and Trackback by HaloScan.com