Recursion in Java

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/19

flashcard set

Earn XP

Description and Tags

Flashcards on Recursion in Java

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

20 Terms

1
New cards

Recursive Definition

A definition that defines something in terms of itself, requiring a base case and an inductive case to avoid infinite regress.

2
New cards

Base Case (Anchor)

Part of a recursive definition that does not reference its own type.

3
New cards

Inductive Case

Part of a recursive definition that contains a reference to its own type.

4
New cards

Recursion

A technique where a method makes one or more calls to itself during execution.

5
New cards

Recursive Program/Algorithm

A program or algorithm that calls itself again during execution.

6
New cards

Three Basic Rules for Developing Recursive Algorithms

Know how to take one step, break down problems into one step plus a smaller problem, and know how and when to stop.

7
New cards

Purposes of Recursive Definition

Generating new elements and testing whether an element belongs to a set.

8
New cards

Contents of an Activation Record (AR)

Parameters and local variables, a dynamic link, return address, and return value.

9
New cards

Return Address

The address of the caller’s instruction immediately following the call.

10
New cards

Run-Time Stack & Activation Records

Each new activation record is placed on the top of the run-time stack; the first AR in is the last one out.

11
New cards

Linear Recursion

Only 1 recursive call inside the recursive function.

12
New cards

Binary Recursion

Exactly 2 recursive calls inside the recursive function.

13
New cards

Multiple Recursion

3 or more recursive calls inside the recursive function.

14
New cards

Tail Recursion

Only one recursive call at the very end of a method implementation.

15
New cards

Non-Tail Recursion

The recursive call is not at the very end of a method implementation.

16
New cards

Indirect Recursion

When f() calls g(), and g() calls f().

17
New cards

Nested Recursion

A function is defined in terms of itself and also used as one of the parameters.

18
New cards

Excessive Recursion (in Fibonacci Sequence)

An implementation of the Fibonacci sequence that looks natural but is extremely inefficient due to repeated calculations.

19
New cards

Rules of the Tower of Hanoi

Only one disk may be moved at a time, each move consists of taking the upper disk from one of the rods and sliding it onto another rod, on top of the other disks that may already be present on that rod. no disk may be placed on top of a smaller disk.

20
New cards

Recursion vs. Iteration

When possible, iteration is usually better due to no overhead of the run-time stack. Some recursive algorithms are very difficult to do any other way.