Discussion:
recursiveness
(too old to reply)
Henry Cheung
2003-11-29 21:06:16 UTC
Permalink
Do we get bonus (or unbonus if we don't) marks for making PrintPath and
PrintEscape themselves recursive, as opposed to having them be normal
functions which call recursive functions?

Asking because the similarity of the two functions means that with small
modifications on the result of a single recursive function, forwards and
backwards instructions can be printed (re: paul's answer to exit-happy
dungeons)

-Jasper
Michael Ens
2003-11-30 01:34:34 UTC
Permalink
Yes, this was addressed in class, as I recall. You can do that.
Post by Henry Cheung
Do we get bonus (or unbonus if we don't) marks for making PrintPath and
PrintEscape themselves recursive, as opposed to having them be normal
functions which call recursive functions?
Asking because the similarity of the two functions means that with small
modifications on the result of a single recursive function, forwards and
backwards instructions can be printed (re: paul's answer to exit-happy
dungeons)
-Jasper
Paul Kishimoto
2003-11-30 01:24:27 UTC
Permalink
You should wait for a Daniel post on this, but a couple of observations:

1. The assignment handout mentions recursive helpers - if they're suggested,
we can't exactly be penalized for using them.
2. Putting the recursion in one function, the overall algorithm in a second
and ONLY an algorithm call and the code for printing in PrintEscape and
PrintPath is, IMHO, reasonable compartmentalization of code. It also makes
each easier to comment ... eg. your algorithm comment for PrintEscape can be
reduced to /* stores the route (if one exists) in TempStack. Prints the
contents of TempStack */ (or whatever). We DO get marks for easy
understanding ...

____________________
Paul Kishimoto

(posting from home)

Loading...