Hi!
Is it possible to implement a merge-sort in Pascal without having
dynamic arrays and without having to use pointers (Linked lists / linear
lists)?
Google only brought up results using pointers...
Thank you!
regards,
Chriss
|
|
0
|
|
|
|
Reply
|
Christian
|
4/22/2004 4:11:50 PM |
|
On Thu, 22 Apr 2004 18:11:50 +0200, Christian Muenscher <crion@gmx.de>
wrote:
>Is it possible to implement a merge-sort in Pascal without having
>dynamic arrays and without having to use pointers (Linked lists / linear
>lists)?
>Google only brought up results using pointers...
Yes, if you can make static arrays large enough for the data.
---
Replace you know what by j to email
|
|
0
|
|
|
|
Reply
|
Jud
|
4/22/2004 5:00:30 PM
|
|
On 2004-04-22, Christian Muenscher <crion@gmx.de> wrote:
> Hi!
>
> Is it possible to implement a merge-sort in Pascal without having
> dynamic arrays and without having to use pointers (Linked lists / linear
> lists)?
> Google only brought up results using pointers...
Only if the number of files is limited.
Without dynamic mem there is no way to keep track of a variable number of
files.
It also depends on what you call merge sort. Is it only the last stage, or
does it involve the creation of the sorted beginfiles also?
|
|
0
|
|
|
|
Reply
|
Marco
|
4/22/2004 8:28:34 PM
|
|
"Christian Muenscher" <crion@gmx.de> wrote in message news:c68qri$9cchh$1@ID-5299.news.uni-berlin.de...
> Hi!
>
> Is it possible to implement a merge-sort in Pascal without having
> dynamic arrays and without having to use pointers (Linked lists / linear
> lists)?
> Google only brought up results using pointers...
>
> Thank you!
>
> regards,
> Chriss
Whats wrong with pointers ?
Anyways, no, ISO 7185 Pascal (the original Pascal) would need
either an array larger than the anticipated data, or pointers.
That (pointers) can be made much more space efficent by allocating
data in "chunks" of 100 or so data items, instead of one data, one
pointer.
In any case, variable length arrays is a common Pascal extention.
Your compiler may offer such a feature.
|
|
0
|
|
|
|
Reply
|
Scott
|
4/23/2004 8:09:24 AM
|
|
Scott Moore wrote:
> "Christian Muenscher" <crion@gmx.de> wrote in message
>>
>> Is it possible to implement a merge-sort in Pascal without
>> having dynamic arrays and without having to use pointers (Linked
>> lists / linear lists)?
>> Google only brought up results using pointers...
>
> Whats wrong with pointers ?
>
> Anyways, no, ISO 7185 Pascal (the original Pascal) would need
> either an array larger than the anticipated data, or pointers.
> That (pointers) can be made much more space efficent by allocating
> data in "chunks" of 100 or so data items, instead of one data, one
> pointer.
>
> In any case, variable length arrays is a common Pascal extention.
> Your compiler may offer such a feature.
There are various flavors of merge sorts. One operates in memory,
preferably on linked lists (which in turn can be implemented in
arrays). Another merges external files, and is basically
unlimited as to final file size. One extreme of this is
poly-phase sort.
--
Chuck F (cbfalconer@yahoo.com) (cbfalconer@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
|
|
0
|
|
|
|
Reply
|
CBFalconer
|
4/23/2004 9:53:41 AM
|
|
I was about to say that myself! About 15 years ago, I wrote a very
primitive spell-checker (hmm -- maybe 20 years ago!) that broke a
manuscript apart into words, sorted the words, then compared them with
a (sorted) dictionary. As I was using a PDP-11 with (I think) at most
2M memory (my memory is starting to go here), I definitely needed an
"external sort" and coded a version of polyphase merge sort, following
the example in Wirth's book "Algorithms + Data Structures = Programs".
Definitely "vanilla Pascal", no dynamic arrays, and no pointers in
this particular program.
Bob Schor
Pascal Enthusiast
On Fri, 23 Apr 2004 09:53:41 GMT, CBFalconer <cbfalconer@yahoo.com>
wrote:
>Scott Moore wrote:
>> "Christian Muenscher" <crion@gmx.de> wrote in message
>>>
>>> Is it possible to implement a merge-sort in Pascal without
>>> having dynamic arrays and without having to use pointers (Linked
>>> lists / linear lists)?
>>> Google only brought up results using pointers...
>>
>> Whats wrong with pointers ?
>>
>> Anyways, no, ISO 7185 Pascal (the original Pascal) would need
>> either an array larger than the anticipated data, or pointers.
>> That (pointers) can be made much more space efficent by allocating
>> data in "chunks" of 100 or so data items, instead of one data, one
>> pointer.
>>
>> In any case, variable length arrays is a common Pascal extention.
>> Your compiler may offer such a feature.
>
>There are various flavors of merge sorts. One operates in memory,
>preferably on linked lists (which in turn can be implemented in
>arrays). Another merges external files, and is basically
>unlimited as to final file size. One extreme of this is
>poly-phase sort.
|
|
0
|
|
|
|
Reply
|
Bob
|
4/28/2004 3:26:58 AM
|
|
|
5 Replies
437 Views
(page loaded in 0.075 seconds)
Similiar Articles: x86-64 and calling conventions - comp.compilers... would be needed, and secondly, that function pointers ... some parts are linked into the executable, and other ... What I'm trying to do, is to merge assembly code and C ... Max # of files allowed in directory under UFS & under VxFS ...... inode in the directory > file (uses a linear ... directory structure started out as a linked list so it could grow without ... If tvpp is non-null, return with the pointer to ... How to check whether malloc has allocated memory properly in case ...When used this way, REAL*8 is sort of a poor man's ... Without the mask, you would get an interrupt where not ... chunk(s), although personally I would keep a linked-list ... Modifying MEX arguments in place? - comp.soft-sys.matlab ...The columns you see might be linked to columns of other ... a(:,:) d = a You can see that the real data pointer pr ... MATLAB provides some sort of in-place operation for ... Misuses of RTTI - comp.lang.c++.moderatedBundling it in the language allows to reuse the pointer to ... Sure, you need some sort of metadata to describe how ... time version is shipped when a dependent module is linked ... top 10 uses for random data compression?? anyone? - comp ...As sort of as Neil robs, you can sound the flag much ... I am forwards hot, so I merge you. Get your ... It linked, you initiated, yet Jbilou never just about ... [comp.publish.cdrom] CD-Recordable FAQ, Part 1/4 - comp.publish ...Archive-name: cdrom/cd-recordable/part1 Posting-Frequency: monthly Last-modified: 2008/10/09 Version: 2.71 Send corrections and updates to And... merge sort for Linked List - pointers: linked list pointers merge sort... two sorted linked list (the second part of the merge sort ... merge sort for Linked List - pointers ... OK: Linear merge sort is that when we divide a list into two ... Mergesort For Linked Lists - chiark home pagePoint another temporary pointer, q, at the same ... it is pointing at the next pair of length-K lists to merge. ... Any situation where you need to sort a linked list. 7/29/2012 8:32:35 AM
|