Page 1 of 3

How to Implement Bubble sort in Cobol ??

PostPosted: Tue Nov 23, 2010 1:01 am
by gauthamnagpur18
I got one task :

i/p : S.no , Name , mark1 , mark2 , mark3

o/p : S.no , Name , mark1 , mark2 , mark3 , Average , Rank

I want to sort as per Rank .(Highest one at top )

There are many method to solve this . but i need to find thru Cobol .

Thanks in advance
Gautham

Re: How to Implement Bubble sort in Cobol ??

PostPosted: Tue Nov 23, 2010 1:20 am
by dick scherrer
Hello,

Take any pseudo-code you have found and write this in cobol. All you should need is an array and a loop. . .

We will help if/when you get stuck, but will not do the work for you.

Re: How to Implement Bubble sort in Cobol ??

PostPosted: Tue Nov 23, 2010 2:51 am
by Akatsukami
To make your life almost tolerable, Gautham, here is the pseudo-code for bubble sort, a discussion of why you shouldn't use it, and links to other sort algorithms.

Re: How to Implement Bubble sort in Cobol ??

PostPosted: Tue Nov 23, 2010 6:49 am
by littlechicken
why not use internal sort

Surely this sort of code is done as student exercises in cobol intro courses I know it was for us 30 years ago.

SUrely learning for yourself is a better way to becoming an expert programmer not he 95% who are not so good coders.

Re: How to Implement Bubble sort in Cobol ??

PostPosted: Tue Nov 23, 2010 6:51 am
by littlechicken
if fact why not do both as an exercise write a array bubble sort then also write the code to sort it as an internal sort

that way you get to learn both ways.

even smarter see if you can do the sort call and use the compile option to use internal cobol sort or external DFSORT/SYNCSORT.

have fun learning its better than being given the code.

Re: How to Implement Bubble sort in Cobol ??

PostPosted: Tue Nov 23, 2010 9:21 am
by dick scherrer
Hello,

why not use internal sort
Because the requirement is to write the cobol code for a bubble sort. . .

Re: How to Implement Bubble sort in Cobol ??

PostPosted: Tue Nov 23, 2010 9:08 pm
by Akatsukami
dick scherrer wrote:Hello,

why not use internal sort
Because the requirement is to write the cobol code for a bubble sort. . .

Is it? I grant that the thread's title is "How to Implement Bubble sort in Cobol??", but the OP seems to suggest that any algorithm is acceptable so long as it is implemented in COBOL. Invoking DFSORT/SyncSort via the COBOL SORT verb probably doesn't fulfill the requirement, but it seems to me that there are a lot of algorithms besides bubble sort that do.

Re: How to Implement Bubble sort in Cobol ??

PostPosted: Wed Nov 24, 2010 2:52 am
by dick scherrer
Hello,

but it seems to me that there are a lot of algorithms besides bubble sort that do
Yup, but this seems to have lasted in many training facilities - probably because it is already "there". . .

The link Akatsukami posted also mentions why bubble sort is not a good choice:
here is the pseudo-code for bubble sort, a discussion of why you shouldn't use it, and links to other sort algorithms.

Re: How to Implement Bubble sort in Cobol ??

PostPosted: Wed Nov 24, 2010 11:56 pm
by gauthamnagpur18
Thanks all for suggesting ideas . I have completed till calculation of average .Now i dunno how to go forward ??

Re: How to Implement Bubble sort in Cobol ??

PostPosted: Thu Nov 25, 2010 2:01 am
by dick scherrer
Hello,

I have completed till calculation of average .
What does this mean?

You need to provide the detail of what you have done, what you are doing, and where/why you are stuck.