From: Mr. G on
Hi,

Is it possible to program the Quicksort Algorithm recursive in Cobol?

I know that it is possible to call SubPrograms with CALL "name" an
give the SubProgram some Data.

What would happen if the SupProgram calls itself? Will that be real
recursive or doesn't that work?

Does somebody already have a conclusion?

Markus
From: Anonymous on
In article <aee81659-5d9a-4562-830f-b2bf1d70a7e3(a)z17g2000hsg.googlegroups.com>,
Mr. G <gronoworx(a)gmx.de> wrote:
>Hi,
>
>Is it possible to program the Quicksort Algorithm recursive in Cobol?

This smells remarkably like homework... but it might not be.

The kind of sort coded that would be most efficient depends on the kind of
data being passed through it; please detail the size and data-type of your
sort key, the length of the data element associated with it and the source
of the data (external file or a WORKING-STORAGE table) and the situation
might be addressed more readily.

DD

From: Robert on
On Thu, 10 Jan 2008 04:24:25 -0800 (PST), "Mr. G" <gronoworx(a)gmx.de> wrote:

>Hi,
>
>Is it possible to program the Quicksort Algorithm recursive in Cobol?
>
>I know that it is possible to call SubPrograms with CALL "name" an
>give the SubProgram some Data.
>
>What would happen if the SupProgram calls itself? Will that be real
>recursive or doesn't that work?

Recursion works if the compiler follows the 2002 Cobol Standadrd or supports object
oriented. But then, if it follows the 2002 Standard for SORT verb, you can sort a table in
memory with one line of code. If not, you can call the C qsort function with one line of
code.

Quicksort is not the fastest, in general. For extra points, try to find a faster sort
algorithm .. or (hint) combination of algorithms.
From: HeyBub on
Robert wrote:
> On Thu, 10 Jan 2008 04:24:25 -0800 (PST), "Mr. G" <gronoworx(a)gmx.de>
> wrote:
>
>> Hi,
>>
>> Is it possible to program the Quicksort Algorithm recursive in Cobol?
>>
>> I know that it is possible to call SubPrograms with CALL "name" an
>> give the SubProgram some Data.
>>
>> What would happen if the SupProgram calls itself? Will that be real
>> recursive or doesn't that work?
>
> Recursion works if the compiler follows the 2002 Cobol Standadrd or
> supports object oriented. But then, if it follows the 2002 Standard
> for SORT verb, you can sort a table in memory with one line of code.
> If not, you can call the C qsort function with one line of code.
>
> Quicksort is not the fastest, in general. For extra points, try to
> find a faster sort algorithm .. or (hint) combination of algorithms.

Or use the SORT verb and let the operating system figure it out.


From: Judson McClendon on
"Mr. G" <gronoworx(a)gmx.de> wrote:
>
> Is it possible to program the Quicksort Algorithm recursive in Cobol?
>
> I know that it is possible to call SubPrograms with CALL "name" an
> give the SubProgram some Data.
>
> What would happen if the SupProgram calls itself? Will that be real
> recursive or doesn't that work?
>
> Does somebody already have a conclusion?

It depends on the COBOL compiler. I once wrote a recursive parts
explosion algorithm in COBOL, and it was very simple and elegant.
That compiler supported recursive performs, but not local recursive data,
so I had to use a table stack for that, which made it a bit less elegant than
I would have liked.
--
Judson McClendon judmc(a)sunvaley0.com (remove zero)
Sun Valley Systems http://sunvaley.com
"For God so loved the world that He gave His only begotten Son, that
whoever believes in Him should not perish but have everlasting life."