How to Implement Bubble sort in Cobol ??



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Re: How to Implement Bubble sort in Cobol ??

Postby Robert Sample » Mon Dec 06, 2010 7:26 pm

I am still struggling to get output . Pls tell me what to do ??? Till average calculation , I have completed ! Next Rank Calculation is little bit tuff for me !!
Why? Once you've got the averages sorted in descending order, the first one gets rank 1. If the second average is the same as the first, it also gets rank 1 -- otherwise it gets rank 2.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: How to Implement Bubble sort in Cobol ??

Postby Balr14 » Fri Dec 10, 2010 1:08 am

Many companies do this with tableBASE. Just load the data into a tableBASE table and define an alternate index. It's very fast.
Balr14
 
Posts: 41
Joined: Fri Oct 01, 2010 9:43 pm
Has thanked: 0 time
Been thanked: 1 time

Re: How to Implement Bubble sort in Cobol ??

Postby enrico-sorichetti » Fri Dec 10, 2010 1:31 am

most probably the TS does not have tableBASE
since this is a A Help & Support Forum for Mainframe Beginners and Students
maybe is just trying to carry on some assignment
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: How to Implement Bubble sort in Cobol ??

Postby dick scherrer » Fri Dec 10, 2010 1:55 am

Hello,

Even if tablebase is on the system, the requirement is to do this using cobol. . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: How to Implement Bubble sort in Cobol ??

Postby GuyC » Wed Dec 22, 2010 3:30 pm

you don't need average for a bubblesort.
All you need is
a loop : perform until
a compare : if A > B
and a SWAP, which in COBOL can only be done by using a additional WS field/record: move A to X . move B to A . move X to B.
GuyC
 
Posts: 315
Joined: Tue Aug 11, 2009 3:23 pm
Has thanked: 1 time
Been thanked: 4 times

Re: How to Implement Bubble sort in Cobol ??

Postby dick scherrer » Thu Dec 23, 2010 1:50 am

Hi Guy,

If i understand, the goal is to sort the averages into ranks (rather than sorting "detail").
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Previous

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post