MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Permutation logic in COBOL

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
MFBaba
Beginner


Joined: 24 Nov 2004
Posts: 8
Topics: 4

PostPosted: Thu Oct 15, 2009 3:45 pm    Post subject: Permutation logic in COBOL Reply with quote

I want to perform a Permutation operation on the values entered by a user and provide as an output all the possible combination of the values.

eg. if user inputs A, B and C all possible output combinations would be (3! = 6): ABC,ACB,BCA,BAC,CAB and CBA

The maximum inputs the user can give is upto 10 values.

I want to use an internal array to store all possible combinations. Would it be better to declare a big array that can work for 10 values or use OCCURS DEPENDING ON clause to create an array based on the number of values input by the user? Any suggestions in this regard would be appreciated.
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Thu Oct 15, 2009 4:07 pm    Post subject: Reply with quote

1. remember a COBOL Interal table defined as occurs 1000 times and an ODO 1 to 1000 both allocate the same space - 1000 items.

2. depends on how you are going to handle the tables and your algorithm to develop the permutations.
Unless you are
  • writing variable length records
  • using SEARCH ALL
your code will be basically the same.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Oct 15, 2009 4:47 pm    Post subject: Re: Permutation logic in COBOL Reply with quote

MFBaba wrote:
The maximum inputs the user can give is upto 10 values.

I want to use an internal array to store all possible combinations.


Just before you venture beware that
Code:

10! =  3,628,800


You are going to define an array of 10 bytes for that number? Good Luck getting the storage and generating the output

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group