0

hi there :)
i'm currently practicing with the recursive backtracking method by trying to solve all the suggested problems...

one of them says: find all the solutions for the next ecuation: 3x + y + 4xz = 100

so the solution would be of type S={(x,y,z) | x,y,z belonging to N}
by now i've tried different stuff like finding a pattern which would guide me then to make the validation part but i couldnt find anything that would work.. i've deduced that each element of the 3 levels of the stack where i build the solution belongs to a set of elements formed only by knowing the other 2 ... can somebody gimme a hint or something?!

3
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by xeption12
0

Isn't stuff like that done by setting one variable to zero in order to find the relationship between the the other two, then resubstitute that relationship?

You could also do a simultaneous equations matrix.
Hope this helps, It's been a while...
Hope that helps

0

Not sure if this defeats the purpose of your program (it's not recursive), but for a problem with numbers as small as this, where everything is natural numbers and less than 100, you could change the equation to:

y = 100 - 3x - 4xz

and do a brute force method. Each value of x and z gives you a value of y. Start with x and z at 0 and check for all value pairs of x and z. Have an outer for loop of x values and an inner for loop of z values. Have each for loop increase by one each time. When y goes negative for a particular x value, bail out of the inner z loop.

0

first of all thanx for replying :)
i've asked my teacher and said that on each level of the stack representing x,y and z there's a value from 0 to 100 (except for the case where x=0, when on the third level representing z can be actually any natural number) so from here everything worked just fine :)

@VernonDozier: i've tried as you said and it worked perfectly too, thanx :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.