Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Recursion Problems

## Definitions
Define the following:
Define the following:

- Recursion
- Recursive Case
- Base Case
- Activation Chain/Stack
- Recursion: Recursion is when you have a method that calls itself. All recursive methods can be written iteratively.
- Recursive Case: The initial case where there isn't a known number.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hmm... this doesn't make sense to me.

I'd say the recursive case is the case in which the method calls itself.

- Base Case: When you finally get to the point where you can input a known number and "work backwards" to get the answer to a recursive problem.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is true.

You could also say a base case is the case which stops the recursion by not calling the method again.

- Activation Chain/Stack: The process in which recursion occurs
- Activation Record/Call
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is one specific call to the recursive method.

- Infinite Recursion/Stack Overflow/Stack too deep
- Tail Recursion
- Infinite Recursion/Stack Overflow/Stack too deep: When a problem can't be solved/will keep going on recursion forever.
- Tail Recursion: The last chain of the recursion.

## Tracing through a recursive method

Expand All @@ -24,7 +24,7 @@ def mystery1(n)
end
```

- What is mystery1(5)?
- What is mystery1(5)? did problems below
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I don't know what this means? I don't see any answers.

- What is mystery1(10)?
- What is mystery1(0)?

Expand All @@ -39,9 +39,9 @@ def mystery2(n)
end
```

- What is mystery2(123)?
- What is mystery2(9005)?
- What is mystery2(-123)?
- What is mystery2(123)? 6
- What is mystery2(9005)? 14
- What is mystery2(-123)? -123
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

These three are correct but are the only answers that I see in this document.

- _Added Fun: How could we make `mystery2(-123)` work the way we might expect it to work instead of the way it does?_

### Trace #3
Expand All @@ -61,7 +61,7 @@ end
```

- What is mystery3(1)?
- What is mystery3(13)?
- What is mystery3(13)? 100
- What is mystery3(-6)?

### Trace #4
Expand Down