Velocity Reviews > Java > Computer Science 101 Question - extracting subsets of a collection

# Computer Science 101 Question - extracting subsets of a collection

Lasse Reichstein Nielsen
Guest
Posts: n/a

 08-10-2005
"jan V" <(E-Mail Removed)> writes:

> Now I'm stumped. I can easily picture the "animating dance" of bits
> switching on and off as you increment from 0 to whatever, but I don't see
> the connection with the OP's problem.. can you give us an extra hint?

What if each number represents a subset?

/L
--
Lasse Reichstein Nielsen - http://www.velocityreviews.com/forums/(E-Mail Removed)
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'

jan V
Guest
Posts: n/a

 08-10-2005
> > Now I'm stumped. I can easily picture the "animating dance" of bits
> > switching on and off as you increment from 0 to whatever, but I don't

see
> > the connection with the OP's problem.. can you give us an extra hint?

>
> abcd
> 0001
> ----
> d
>
> abcd
> 0010
> ----
> c
>
> abcd
> 0011
> ----
> cd

That is *so* neat. Don't you just love efficient *and* elegant solutions
like that. Cool.

Steve Wampler
Guest
Posts: n/a

 08-10-2005
On Wed, 10 Aug 2005 22:02:30 +0000, jan V wrote:
>>...
>> abcd
>> 0010
>> ----
>> c
>>
>> abcd
>> 0011
>> ----
>> cd

>
> That is *so* neat. Don't you just love efficient *and* elegant solutions
> like that. Cool.

Hmmm, I agree that's a neat approach, but isn't there a fair amount
of gunk that has to be done to complete the solution? For example,
you have to 'walk the bits' to extract the symbols in each subset,
and all the subsets are 'jumbled' (i.e. the length (n-1),(n-2), etc.
collections are interleaved). If I recall correctly, the
OP needed each collection separately. Granted, that's all just
tedium layered on top of the above elegance, and certainly not
hard.

Another approach is to do a breadth-first traversal of the
solution space (which is a DAG), but I'm pretty sure that
approach is well beyond CS 101...

Eric Sosman
Guest
Posts: n/a

 08-10-2005

jan V wrote:
>>>Now I'm stumped. I can easily picture the "animating dance" of bits
>>>switching on and off as you increment from 0 to whatever, but I don't

>
> see
>
>>>the connection with the OP's problem.. can you give us an extra hint?

>>
>>abcd
>>0001
>>----
>> d
>>
>>abcd
>>0010
>>----
>> c
>>
>>abcd
>>0011
>>----
>> cd

>
>
> That is *so* neat. Don't you just love efficient *and* elegant solutions
> like that. Cool.

For extra credit, give a simple formula for the number
of subsets of a set of N elements. For extra extra credit,
give a plausible reason why the set of all subsets of a
given set is known as its "power set."

<off-topic>

Georg Cantor showed that the cardinality of a set is
strictly less than the cardinality of its power set. This is
"obvious" for finite sets, but Cantor proved that it's true
for infinite sets as well -- thus establishing the existence
of not just one infinity, but an infinitude of infinities of
different sizes.

</off-topic>

We now resume our regularly scheduled programming.

--
(E-Mail Removed)

Roger Varley
Guest
Posts: n/a

 08-11-2005
Actually it's not a "class" question. I used the CS101 in the heading
tongue in cheek because I suspected that I was asking a pretty basic
question. I've spent the last <mumble> years programming in a
commercial enviornment using languages that don't permit recursion (RPG
anyone?) and I'm only just coming to the Java party.

Regards
Roger

jan V
Guest
Posts: n/a

 08-11-2005
> commercial enviornment using languages that don't permit recursion (RPG

Get the sharp wooden stake, and the garlic, QUICK !! RPG in 2005, for
*goodness* sake............. The company you work for must be led by truly
enlightened bosses/managers, eh ? Sheesh.

Eric Sosman
Guest
Posts: n/a

 08-11-2005

jan V wrote:
>>commercial enviornment using languages that don't permit recursion (RPG

>
>
> Get the sharp wooden stake, and the garlic, QUICK !! RPG in 2005, for
> *goodness* sake............. The company you work for must be led by truly
> enlightened bosses/managers, eh ? Sheesh.

That's right: It is a capital offense to fail to stay

(If you don't think the computer industry is fashion-
driven, you're not thinking.)

--
(E-Mail Removed)

jan V
Guest
Posts: n/a

 08-11-2005
> That's right: It is a capital offense to fail to stay abreast of the

That's not exactly what I said, is it?

> (If you don't think the computer industry is fashion-driven, you're not

thinking.)

I totally agree with you that there's a strong bandwagon force. See my post
hinting at such in relation to XML.

But I definitely don't consider Java itself as a fad. Companies have had
almost an eternity (nearly 10 years) to decide whether Java could bring them
the benefits that the rest of the world using Java are experiencing... I
think any company still using Cobol/RPG/etc.. in this day and age needs to
have their CTO/IT manager fired on the spot.

Eric Sosman
Guest
Posts: n/a

 08-11-2005

jan V wrote:
>> That's right: It is a capital offense to fail to stay abreast of the

>
>
> That's not exactly what I said, is it?
>
>
>> (If you don't think the computer industry is fashion-driven, you're not

>
> thinking.)
>
> I totally agree with you that there's a strong bandwagon force. See my post
> hinting at such in relation to XML.
>
> But I definitely don't consider Java itself as a fad. Companies have had
> almost an eternity (nearly 10 years) to decide whether Java could bring them
> the benefits that the rest of the world using Java are experiencing... I
> think any company still using Cobol/RPG/etc.. in this day and age needs to
> have their CTO/IT manager fired on the spot.

If you'll pardon my saying so: bullshit.

You've just been promoted to CTO of a company that's been
using COBOL and RPG and Autocoder for the last forty years.
Over that time their programming staff has averaged, say, a
dozen people -- so they've got 480 person-years invested in
their software. (This is by no means a "large" enterprise;
plenty of shops have much larger investments.)

Even though it's a modest investment, let's cut it down
a little more just to be generous. Let's say that over forty
years they've decommissioned and replaced two-thirds of the
software they developed. The investment in the code they're
actually using today is a mere 160 person-years.

So: Your first directive to the staff is "All that stuff
you're doing is obsolete, unfashionable, and objectionable.
I forbid you to do any more work on it. You're all going to
Fad Of The Moment school, and when you come back you'll all
get busy replacing the Bad Stuff with Fad Stuff. Make it so."

So your staff of a dozen drop everything and go away to
school, and they all come back trained to the gills and able
to work five times more productively with Fad than they ever
did with Bad. How long will it take them to rewrite all the
existing applications?

Thirty-two months.

Are you going to spend two and two-thirds years of your
IT budget for no net advance in the application services you
can deliver?

What are you going to do when the CEO calls for a new
IT initiative requiring new applications? Tell him "Sorry,
but we're booked solid through April 2009?"

Who deserves to be fired on the spot: the manager who
makes productive use of a legacy, or the one who ****es
away his inheritance?

Okay, so I've made up a lot of numbers out of thin air
(I've made them up to be as favorable to your position as I
could, by the way.) Still, they're thin-air numbers and not
very convincing. So let's boil it down to one decision you
might need to make as CTO: One of your applications depends
on the dates of the Daylight Savings seasonal time adjustment,
and the U.S. Congress has just passed a law changing the way
forecast the exact date on which your application will start
misbehaving if it isn't fixed. One of your programmers says
"No problem, boss: The folks who wrote that RPG program made
it easy to carry out adjustments of this sort; it'll be a
three-line change."

--
(E-Mail Removed)

Dale King
Guest
Posts: n/a

 08-14-2005
Eric Sosman wrote:
>
> jan V wrote:
>
>>> That's right: It is a capital offense to fail to stay abreast of the

>>
>>
>>That's not exactly what I said, is it?
>>
>>
>>
>>> (If you don't think the computer industry is fashion-driven, you're not

>>
>>thinking.)
>>
>>I totally agree with you that there's a strong bandwagon force. See my post
>>hinting at such in relation to XML.
>>
>>But I definitely don't consider Java itself as a fad. Companies have had
>>almost an eternity (nearly 10 years) to decide whether Java could bring them
>>the benefits that the rest of the world using Java are experiencing... I
>>think any company still using Cobol/RPG/etc.. in this day and age needs to
>>have their CTO/IT manager fired on the spot.

>
>
> If you'll pardon my saying so: bullshit.
>
> You've just been promoted to CTO of a company that's been
> using COBOL and RPG and Autocoder for the last forty years.
> Over that time their programming staff has averaged, say, a
> dozen people -- so they've got 480 person-years invested in
> their software. (This is by no means a "large" enterprise;
> plenty of shops have much larger investments.)
>
> Even though it's a modest investment, let's cut it down
> a little more just to be generous. Let's say that over forty
> years they've decommissioned and replaced two-thirds of the
> software they developed. The investment in the code they're
> actually using today is a mere 160 person-years.
>
> So: Your first directive to the staff is "All that stuff
> you're doing is obsolete, unfashionable, and objectionable.
> I forbid you to do any more work on it. You're all going to
> Fad Of The Moment school, and when you come back you'll all
> get busy replacing the Bad Stuff with Fad Stuff. Make it so."
>
> So your staff of a dozen drop everything and go away to
> school, and they all come back trained to the gills and able
> to work five times more productively with Fad than they ever
> did with Bad. How long will it take them to rewrite all the
> existing applications?
>
> Thirty-two months.
>
> Are you going to spend two and two-thirds years of your
> IT budget for no net advance in the application services you
> can deliver?
>
> What are you going to do when the CEO calls for a new
> IT initiative requiring new applications? Tell him "Sorry,
> but we're booked solid through April 2009?"
>
> Who deserves to be fired on the spot: the manager who
> makes productive use of a legacy, or the one who ****es
> away his inheritance?
>
> Okay, so I've made up a lot of numbers out of thin air
> (I've made them up to be as favorable to your position as I
> could, by the way.) Still, they're thin-air numbers and not
> very convincing. So let's boil it down to one decision you
> might need to make as CTO: One of your applications depends
> on the dates of the Daylight Savings seasonal time adjustment,
> and the U.S. Congress has just passed a law changing the way
> the adjustment is made. The clock is ticking, and you can
> forecast the exact date on which your application will start
> misbehaving if it isn't fixed. One of your programmers says
> "No problem, boss: The folks who wrote that RPG program made
> it easy to carry out adjustments of this sort; it'll be a
> three-line change."

I'd say the answer lies somewhere between the two extremes. It is not a
sin if someone is still using Cobol or RPG. Many people have legacy
software to deal with and it takes a lot of resources to convert over.

But anyone that doesn't have a plan in place to move away from that
outdated technology is in for a world of hurt. You can't just bury your
head in the sand and say I've got a lot invested in this. That just
isn't sustainable long term.

What happens when the equipment breaks down. Will you still be able to
get the hardware to run the old software on?

I would venture to say the majority of that programming staff with all
that experience is nearing retirement. Who are you going to get to
replace them? That 480 person year investment is going to plummet very
quikcly. New programmers entering the workforce aren't learning Cobol
and RPG and have no interest in working with 40 year old technology. It
will quickly become impossible to find someone to even make that 3 line
change.

I heard someone talking recently about the same thing in relation to the
space shuttle. The shuttle program has been going for 30 years. Most of
the people who worked on it in the beginning are retiring and the new
people don't have the experience.

--
Dale King