All things are lawful, but not all things are profitable.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
fred rosenberger wrote:have you worked out - on paper - how to do it yourself?
an example is great, but it isn't really a spec. Do you think you could give those directions to a child and they could accurately compute it?
Kaspersky Ukshini wrote:Dude, honestly! I have nooo clue! ):
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:Well, it is too late now, for the upcoming exam and brainstop,
but maybe you could sort the array, from high to low. Of course,
you loose the original positions, and that is very nasty,
but maybe there is a possibility to somehow keep the
original positions.
But even so, what use would all this be ? Hmm...
Greetz,
Piet
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Kaspersky Ukshini wrote:
I don't think sorting the list would somehow help...
(...)
There are three kinds of actuaries: those who can count, and those who can't.
All things are lawful, but not all things are profitable.
Knute Snortum wrote:Think about what you would actually do, remembering that the computer is forgetful and stupid.
I start at the first element I look for the next element that's lower I write down the elements that are in the subarray When I get to the end of the original array, I look at the subarray's length There might be another subarray, so I start at the second element of the original array I do the above steps again I check if my new subarray is longer than the other subarray
...Are you getting the idea?
Piet Souris wrote:
Kaspersky Ukshini wrote:
I don't think sorting the list would somehow help...
(...)
Well, take Fred's array:
546 -156 165 -156 -56 -13 5
and suppose that we sort it, keeping the original positions.
We get this:
Looking at this, anything that comes up? Take a special look at the original positions.
Greetz,
Piet
All things are lawful, but not all things are profitable.
Piet Souris wrote:But even so, what use would all this be ? Hmm...
Kaspersky Ukshini wrote:I believe im close.. I've decided to use a new class of arrays, each holding the value and it's index.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Kaspersky Ukshini wrote:I believe im close.. I've decided to use a new class of arrays, each holding the value and it's index.
Then I'm trying to convert the curent Array into my new one:
And NO LUCK! I'm getting this error when trying it: Exception in thread "main" java.lang.NullPointerException
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
There are three kinds of actuaries: those who can count, and those who can't.
Chan Ag wrote:
3.2 If its larger than the root, start another tree with the node you read as the root. (There are some improvements possible as you traverse your trees -- you can ignore some trees -- but I will leave that up to you )
Chan Ag wrote:I have only tried an algorithm on paper so far. I mean no programming. Just some tree nodes and diagrams.
There are three kinds of actuaries: those who can count, and those who can't.
Winston Gutkowski wrote:I doubt that the structure involves just a single root (because there could be more than one "maximal" subsequence
Kaspersky Ukshini wrote:I believe im close.. I've decided to use a new class of arrays, each holding the value and it's index.
Then I'm trying to convert the curent Array into my new one:
And NO LUCK! I'm getting this error when trying it: Exception in thread "main" java.lang.NullPointerException
Kaspersky Ukshini wrote:
Kaspersky Ukshini wrote:
And NO LUCK! I'm getting this error when trying it: Exception in thread "main" java.lang.NullPointerException
Guys, I think I found my way around it, I just need help with this detail.. what am I mising here?
Ater you declare and initialize the index array at line 6 it contains only null references.
You then dereference null inside your for-loop by invoking setValue() which results in a NullPointerException.
Piet Souris wrote:
{ {2} }
{ {8,2} , {2} , {8}}
{ {8,2}, {4, 2}, {2} , {8} , {4} }
And so the longest subsequence is either {8, 2} or {4, 2}
The only worry is that the number of LinkedLists is increasing at
an alarming rate, about 2^n, which is deadly for any algorithm.
Guess I'll have to do some extra study...
There are three kinds of actuaries: those who can count, and those who can't.
Chan Ag wrote: I think it's asymptotic computational complexity is close to O(N log N) as we are only adding each node at one place only and we are examining only the applicable nodes.
BWA HA HA HA HA HA HA! Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|