You are not logged in.
Pages: 1
Thanks
im not trying to apply it on anything, its just a question that was given to me and just want to know the answer to it and how you would go about coming to that conclusion - its just mind boggling
hmmm. so given this:
1, 2, 3, 4, 5
largest subset would be...all of it?
gotcha...thanks for that
so again back to my question, how would you find the largest number in a subset? or the largest number within A subset
Thanks folks. much appreciated. Just need to try and understand all this for general purposes...you never know when you will get a question like that....and I did and messed it up bad!
so your saying that if we have:
1, 2, 3, 4, 5
we can have subsets:
1 = 1
1 + 2 = 3
1 + 2 + 3 = 6
1 + 2 + 3 + 4 = 10
1 + 2 + 3 + 4 + 5 = 15
I think i follow your Set Theory example....
so given the numbers in this reply, what would be the largest number in the subset?
uh thanks folks, sorry i dont understand or know what this whole formula thing is (the whole max { w, x, y, z}.....
thanks for the code, yes I follow it and you are right I DID miss setting the largeNumber to the first element in the array.
drats. ok.... so basically you should be checking the NEXT number in the array to see if it is larger than the stored number in a temp variable. - but there is no point in doing that in your code since your kind of doubling the check....
foreach item in array
if currentitem + 1 in array > storedNumber
.. do stuff
end if
it is the same as:
for each item in array
if current item > storedNumber
//do stuff
end if
with the last example being more effecient....but anyway thats a coding thing.
just still not sure about the whole B is a subset of A...C is a subset of B (and A?)
John - are you sure? Because thats what I did and have a strong suspicion i have done this wrong. OK let me put it in some form of pseudo....
largeNumber = 0
total = 0
foreach number in arrayOfNumbers
total = total + number
if number > largeNumber then
largeNumber = number
end if
end foreach
for some reason I still think its wrong, it probably is. What IS a "subset" of a given set of numbers? What does that mean?
Im not good at math, or even algorithms. I'm actually a software dev and just wondered if someone could give me an explanation and logic on how this is done.
say you are given an array of numbers. how do you find out the largest number in that subset? Example:
1, 2, 3, 4, -3, 8, 0, -20, 6
Pages: 1