Re: recursive classes

From: Andy (andyfaeglasgow_at_yahoo.co.uk)
Date: 06/25/04


Date: 25 Jun 2004 09:45:18 -0700

Hi John,

Before writing this post I must declare that this problem is part of a
dissertation I'm writing for an MSc...so don't be too forthcoming with
solutions or else I'll feel as if I haven't earned it ;-)

However, the problem is quite an interesting one and you might like to
hear about it so...

The two classes represent entities that have preferences over one
another. So for example

class Man {

   List preferences; //is an ordered list of Woman objects
}

class Woman {

   List preferences; //is an ordered list of Man objects
}

The interesting part is that you have to pair up the Man and Woman
objects such that no member of any pair could find a better partner
than the one they are allocated with (given the preferences of all the
"opposing" objects).

A bonus puzzle (for added kudos) is that one of the objects should be
allowed to express indifference in their preferences; so for example,
woman#1 likes man#1 better than both man#2 and man#3, but is
indifferent between man#2 and man#3.

The actual algorithm for the problem has already been published; all I
have to do is implement it in java.

Have fun with it,

Andy

ps I'm serious about the declaration at the top. I'm not looking for
easy answers here, I just thought you might be interested :)



Relevant Pages

  • Re: java 1.5 - generics "unchecked cast" suppression
    ... Writing them is easy, ... there is a serialized-object problem here. ... > I save them as text, I then read the preferences back from the user file. ... >> specify the class to cast to as a separate argument. ...
    (comp.lang.java.help)
  • Re: null terminated strings
    ... it is nice to not have to declare such. ... Even a programmer with a poor typewriting does not use that much time typing the code his writes. ... It will take you much longer time finding that bug with a debugger than if it is reported by the compiler. ... I have a hunch that writing and using that utility has taken you a sizable fraction of the time you have save not writing declarations. ...
    (comp.os.vms)
  • Re: XP has no significant bugs other than those of its defenders
    ... What started this was your writing: "I ain't flaming you, ... need to see how viruses work before you can declare every OS to be ...
    (sci.electronics.design)
  • Function Parameter
    ... I am writing a function which will take two parameters. ... to be returned from a table and second parameter is the ID of the ... DECLARE @ResultVar varchar ...
    (comp.databases.ms-sqlserver)
  • Re: STS51L Accident Questions
    ... I was declared part of the conspiracy to cover up the truth about US ... Gubmint involvement with alien flying saucers after writing an article ... off another discussion forum ... I'm sure someone will declare me to be part of the Great Conspiracy ...
    (sci.space.history)

Loading