0

I have a question where there are four arrays, two for men and two for women. One of the men array is the age in increasing order and the other array is the height of men in increasing order. The two arrays for women are also the same.

Now if one of the men marries a women, then form the age array, the men to the left of this man should marry the women to the left of the lady. and the men right to this man should marry the women to the right of this lady.

Eg: if Mens ages array is {8,9,23,25,27,28,..} and womens age array is {7,9,12,20,28,...} and if the man with age 27 marries the lady with age 20, then the men with ages 8,9,23,25 should marry a lady from 7,9,12. and like wise with the right side men.

NO matter if they do not marry, but if at all they marry, that should be the case.

After marriage, they have children based on the height arrays. If the height difference between the couple is 0 then they have 7 children, if the height difference is 1-2 then they have 6 children, if the height difference is 3-4 then they have 5 children,..... like wise if the height difference is 13 or more then they have 0 children.

So i need an algorithm which can maximize the number of children.I need the maximum number of children.

It can be any language, basically I need an algorithm.

6
  • 1
    @Raviteja: if this is homework, tag it as such. People will provide answers aimed at someone learning instead of simply spoiling the answer. Commented Dec 6, 2009 at 8:17
  • @Raviteja - what you really need is the knowledge that comes DOING YOUR OWN HOMEWORK! Commented Dec 6, 2009 at 8:32
  • Who comes up with homework questions like that? The number of children depends on delta height? ROFL. And I hope the age arrays don't actually go down to 7 year old girls. I guess fair enough if you need to plan the future of your moon colony, except that their current heights won't be their adult heights, and you're not going to have them marry until they're adults (right?). You haven't said how the height and age arrays are linked. Or are we to assume that each person has the same position in both arrays, so the height and age sort order is the same? Commented Dec 6, 2009 at 8:34
  • That ages are just examples.... i just made it up, Ignore the ages... Commented Dec 6, 2009 at 8:36
  • Yes the heights and age sort order is the same Commented Dec 6, 2009 at 8:36

1 Answer 1

2

This sounds like a problem in Discrete Optimization .

Ideally, whoever gave you this assignment shouldn't have dropped it on you without first giving you some theory on how to do this kind of stuff. But if your teacher wants to see you solve problems like this out of the blue, this keyword and link may help get you started.

I'd also recommend telling us which programming language, if any, you are fluent in. The folks here on SO (together) know most programming languages and can make suggestions tailored to be most understandable to you.

Sign up to request clarification or add additional context in comments.

1 Comment

i just need the algorithm, no the program,, so basic algorithm should be same for any language, right?. Can anyone give me some basic idea.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.