Skip to content

Conversation

@sahanamurthy
Copy link

Recursion Tracing

Thanks for doing some brain yoga. You are now submitting this assignment!

Comprehension Questions

Question Answer
Did you define all the recursion terms? Yes
How do you feel about tracing recursive problems? (good, bad, ugly, neutral) Good!
Would you like help/follow up about recursion? Maybe? I think it couldn't hurt to get extra practice in some of those more complicated ones.

- Activation Chain/Stack
- An Activation chain/stack is the entire process of solving the recursive method and getting the appropriate answer.
- Activation Record/Call
- An activation record/call is each little "bubble" within the activation chain. I take that to mean that an activation record occurs each time a recursive case occurs within an activation chain.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct.

- Infinite Recursion/Stack Overflow/Stack too deep
- Infinite recursion occurs when the recursive cases are not leading to a base case.
- Tail Recursion
- Tail recursion occurs when the last computation within a method is a recursive call. All our recursive methods from the homework are examples of Tail recursion.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of our examples in the homework are of Tail Recursion.

I didn't actually have time to cover tail recursion in class. I may in the future, but in this moment you don't need to know it.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WAIT! I LIEEEEEEEE! There is a tail recursive one. Namely: mystery3

- What is mystery3(13)?
- 100
- What is mystery3(-6)?
- stack level too deep (checked my answer and found out I had it wrong. Worked on it until I got the correct answer: 200)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)

- What is mystery6("Hi, there!")?
- " there! Hi,"
- _Added Fun: How could we make the reversal happen by letter, instead of by word (i.e. Make it so that mystery6("goodnight moon") returned "noom thgindoog")?_
- I am not sure. :(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine. It was only a challenge question :)

# end
# return mystery6(s[(space+1)..-1]) + " " + s[0...space]
# end
# end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure if you did anything to this file or not. Github is confusing me. :/

@sudocrystal
Copy link

Recursion Tracing

nice job

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants