Re: Merge sort
- From: //\\\\o//\\\\annabee <Wannabee@xxxxxxxxxxxx>
- Date: Sun, 28 Jan 2007 04:52:41 -0000
På Sat, 27 Jan 2007 14:16:01 -0000, skrev Frank Kotler <fbkotler@xxxxxxxxxxx>:
//\\o//\\annabee wrote:På Sat, 27 Jan 2007 10:23:02 -0000, skrev Foolad <fooladgh@xxxxxxxxx>:
Hello,Whats a merge sort?
Can anybody help me implementing merge sort algorithm with 68000
assembly language?
I don't know where to begin.
Thanks.
Wannabee, let me introduce you to my friend Google!
http://en.wikipedia.org/wiki/Merge_sort
The gist of it is:
-------------------------
Conceptually, merge sort works as follows:
1. Divide the unsorted list into two sublists of about half the size
2. Sort each of the two sublists recursively until we have list sizes of length 1, in which case the list itself is returned
3. Merge the two sorted sublists back into one sorted list.
The algorithm was invented by John von Neumann in 1945.
------------------
Ok. "Sound" a like a variant of "quicksort".
These "recursive" sorts don't *sound* to me like they'd be fast, but apparently they are (depending on data, apparently).
Quicksort can be fast. So I guess mergesort will be too as they both
seems to me like a form of "binary search".
A recursive implementation is not a must. You can change a recursive
approach to a non-recurive one, in not to much of a hassle in most
cases.
Why do you want one, and what is the problem you need to solve?
Well, sounds like it might be homework. He wants to implement a merge sort in 68k assembly (Do *you* know any 68k assembly? I don't!), "why" is his business...
I am supposing 68k here means an amiga or similar.
Lets just say. I have seen it. A friend of mine swore to it the same way Herbert does.
If you don't know where to begin, Foolad, start with what you're given - the data to sort. In what form will this data be, and how will you access it? How will you determine where the "middle" is? How will you divide it into two lists? I suspect this will involve memory allocation, so learn how to do that on your system, if you don't know. Your routine will be more flexible if you can provide the actual comparison routine as a "callback". Then "repeat until done", I guess, and spew it back somehow. The "somehow" may be specified in the assignment/program-specs. Good luck!
Best,
Frank
.
- References:
- Merge sort
- From: Foolad
- Re: Merge sort
- From: //\\\\o//\\\\annabee
- Re: Merge sort
- From: Frank Kotler
- Merge sort
- Prev by Date: Re: Merge sort
- Next by Date: traslation
- Previous by thread: Re: Merge sort
- Next by thread: Re: Merge sort
- Index(es):
Relevant Pages
|