Click here to Skip to main content
14,635,090 members
Home » Discussions » C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Recursion to normal way Pin
iNoor728-Jun-20 11:01
MemberiNoor728-Jun-20 11:01 
GeneralRe: Recursion to normal way Pin
harold aptroot8-Jun-20 11:11
Memberharold aptroot8-Jun-20 11:11 
GeneralRe: Recursion to normal way Pin
iNoor728-Jun-20 11:39
MemberiNoor728-Jun-20 11:39 
GeneralRe: Recursion to normal way Pin
Dave Kreskowiak8-Jun-20 16:44
mveDave Kreskowiak8-Jun-20 16:44 
AnswerRe: Recursion to normal way Pin
Member 79891228-Jun-20 10:38
MemberMember 79891228-Jun-20 10:38 
GeneralRe: Recursion to normal way Pin
iNoor728-Jun-20 11:03
MemberiNoor728-Jun-20 11:03 
GeneralRe: Recursion to normal way Pin
Richard MacCutchan8-Jun-20 21:33
mveRichard MacCutchan8-Jun-20 21:33 
GeneralExercise Pin
Member 79891228-Jun-20 22:31
MemberMember 79891228-Jun-20 22:31 
Trying to evade the problem that you don't understand recursion by rewriting it to non-recursion is never going to work.

In my university days, a fellow student realized that he did not fully master recursion - termination in particular. So he defined a small programming problem for himself. After solving the task, he never had any problems with how to terminate a recursion. I think he made an excellent "programming etude", and have spread it out to a lot of people. It goes like this:

When you enter the recursive function, you write a line with the number of spaces given by the recursion depth, and then an asterisk. When you leave the recursive function, you do the same. The top level call gives parameters for (a) the maximum recursion depth, which you dive right into, (b) an intermediate recursion depth that you return to, before again recursing to the maximum depth, and (c) the number of times to recurse to the maximum depth and back to the intermediate level, before finally returning to the top level call (i.e. the number of "peaks").

For a call with arguments (5, 3, 3) the ouput should look something like
*
 *
  *
   *
    *
    *
   *
  *
   *
    *
    *
   *
  *
   *
    *
    *
   *
  *
 *
*
The problem statement seems very simple (and it is, for a seasoned recursionist). For an inexperienced programmer, you can usually hear a lot of cursing and re-cursing during the testing Smile | :)
GeneralRe: Exercise Pin
Richard MacCutchan8-Jun-20 22:34
mveRichard MacCutchan8-Jun-20 22:34 
JokeRe: Exercise Pin
Peter_in_27808-Jun-20 22:43
professionalPeter_in_27808-Jun-20 22:43 
GeneralRe: Exercise Pin
Member 79891229-Jun-20 2:50
MemberMember 79891229-Jun-20 2:50 
GeneralRe: Exercise Pin
Richard MacCutchan9-Jun-20 3:39
mveRichard MacCutchan9-Jun-20 3:39 
GeneralRe: Exercise Pin
Member 79891229-Jun-20 3:59
MemberMember 79891229-Jun-20 3:59 
GeneralRe: Exercise Pin
Richard MacCutchan9-Jun-20 4:11
mveRichard MacCutchan9-Jun-20 4:11 
GeneralRe: Exercise Pin
Richard MacCutchan9-Jun-20 4:29
mveRichard MacCutchan9-Jun-20 4:29 
GeneralRe: Exercise Pin
Richard MacCutchan9-Jun-20 20:56
mveRichard MacCutchan9-Jun-20 20:56 
GeneralRe: Exercise Pin
Member 79891229-Jun-20 22:08
MemberMember 79891229-Jun-20 22:08 
GeneralRe: Exercise Pin
Richard MacCutchan9-Jun-20 23:33
mveRichard MacCutchan9-Jun-20 23:33 
QuestionIs there any opensource version of telnet client library(encrypted) available for windows Pin
Member 147721178-Jun-20 2:25
MemberMember 147721178-Jun-20 2:25 
AnswerRe: Is there any opensource version of telnet client library(encrypted) available for windows Pin
Richard MacCutchan8-Jun-20 5:31
mveRichard MacCutchan8-Jun-20 5:31 
QuestionEfficient way to read/write file Pin
manoharbalu7-Jun-20 22:32
Membermanoharbalu7-Jun-20 22:32 
AnswerRe: Efficient way to read/write file Pin
CPallini8-Jun-20 1:28
mveCPallini8-Jun-20 1:28 
AnswerRe: Efficient way to read/write file Pin
Greg Utas8-Jun-20 2:23
professionalGreg Utas8-Jun-20 2:23 
AnswerRe: Efficient way to read/write file Pin
Member 79891228-Jun-20 4:32
MemberMember 79891228-Jun-20 4:32 
AnswerRe: Efficient way to read/write file Pin
Joe Woodbury8-Jun-20 14:24
professionalJoe Woodbury8-Jun-20 14:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.