hello,
for a class I have to take some ugly written code and rewrite it but I have ran into some problems. I'm not too sure how backtracking search and in particular this line is really confusing: o = i==0? 0: s[i-1]; If anybody could explain what's going on in this program and specifically what that line means I would greatly appreciate it. Thank you.
help with syntax and backtracking search
Started by TigerUppercut, Feb 19 2007 04:07 PM
2 replies to this topic
#1
Posted 19 February 2007 - 04:07 PM
|
|
|
#2
Posted 19 February 2007 - 04:08 PM
#3
Posted 21 February 2007 - 04:53 AM
o = i==0? 0: s[i-1];means:
if (i == 0) {
o = 0;
} else {
o = s[i-1];
}
I think it's called the ternary operator and it's used as a shorthand for simple if-else statements.
As for the program: I don't really have a lot of time to look at it right now, and I think it would really help if you would just try translating the program into something more legible. Both for yourself as for other people that might try to help you.
I just looked at it real quick and I think the program is looking for a permutation of the numbers 1 to N, but I'm not sure what the criteria are for what sort of permutation is valid.


Sign In
Create Account

Back to top









