Chap 8 (Recursion)

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/43

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 6:03 PM on 4/1/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

44 Terms

1
New cards

What is recursive thinking

The expectation of finding simpler versions of a large problem during the design process.

2
New cards

What is recursion in programming

When a method activates itself to solve a problem.

3
New cards

What is a recursive method

A method that calls itself to solve smaller versions of a problem.

4
New cards

What is the stopping case (base case)

A case where the problem is simple enough to be solved without recursion.

5
New cards

What is a recursive call

A method activating itself to solve a simpler instance of the same problem.

6
New cards

What happens if there is no stopping case

The recursion will not terminate and may cause a StackOverflowError.

7
New cards

How are digits extracted in writeVertical

Using number/10 for all but last digit and number % 10 for the last digit.

8
New cards

What does number/10 represent in recursion

A simpler version of the original number with one fewer digit.

9
New cards

What does number % 10 represent

The last digit of the number.

10
New cards

What is the purpose of writeVertical

To print the digits of a non-negative integer vertically.

11
New cards

How does recursion handle negative numbers in superWriteVertical

It prints a negative sign and calls itself with -number.

12
New cards

What is an activation record

A memory block storing parameters, local variables, and return location for a method.

13
New cards

What is the execution stack

A stack data structure that stores activation records during method calls.

14
New cards

What happens when a method is called

Execution pauses, information is saved, and a new activation record is created.

15
New cards

What happens when a method finishes

Its activation record is removed and execution returns to the previous method.

16
New cards

Why must recursive calls eventually stop

To prevent infinite recursion and program failure.

17
New cards

What is infinite recursion

When recursive calls never reach a stopping case.

18
New cards

What error occurs from infinite recursion

StackOverflowError.

19
New cards

What is a fractal

An object that exhibits similarity under magnification.

20
New cards

What is a random fractal

A fractal generated using random variations.

21
New cards

How is the midpoint calculated in randomFractal

midX = (leftX + rightX)/2 and midY = (leftY + rightY)/2.

22
New cards

What is delta in randomFractal

A random vertical shift applied to the midpoint.

23
New cards

What is the purpose of recursive calls in randomFractal

To generate fractals for smaller line segments.

24
New cards

What is the stopping condition in randomFractal

When the horizontal distance is small enough, draw a line.

25
New cards

What does drawLine do

Draws a line between two points on a Graphics object.

26
New cards

What is the role of the Graphics object

It allows drawing images using pixel coordinates.

27
New cards

What is the purpose of traverseMaze

To guide a user through a maze and back out.

28
New cards

What is the stopping case in traverseMaze

When the tapestry is found.

29
New cards

What is a dead end in the maze

A direction blocked by a wall or already visited.

30
New cards

Why does traverseMaze avoid revisiting spots

To prevent infinite loops.

31
New cards

What is backtracking

Returning to a previous point after exploring a path that failed.

32
New cards

What is exhaustive search

Trying all possible paths to find a goal.

33
New cards

What is the role of marking in maze traversal

To track visited locations and avoid repetition.

34
New cards

What does the inquire method do

Asks a yes/no question and returns true or false.

35
New cards

How does deadend determine a blocked path

By checking for a wall or a previously visited location.

36
New cards

What is the goal of the Teddy Bear game

To reach a target number of bears within a limited number of steps.

37
New cards

What are the two moves in the Teddy Bear game

Add increment bears or halve the bears if even.

38
New cards

What is the stopping case in bears method

When initial equals goal.

39
New cards

What happens when no steps remain in bears

The method returns false.

40
New cards

How does recursion help solve the bears problem

By exploring possible moves as smaller subproblems.

41
New cards

What is the purpose of the power method

To compute x raised to the power n.

42
New cards

How are negative exponents handled in power

By returning 1/power(x, -n).

43
New cards

What is the base case for exponentiation

When n equals 0, the result is 1.

44
New cards

Explore top flashcards

flashcards
AP gov
152
Updated 1172d ago
0.0(0)
flashcards
Cells Structure
30
Updated 1234d ago
0.0(0)
flashcards
Islam Glossary
41
Updated 160d ago
0.0(0)
flashcards
FDNT 151 test 1
80
Updated 1150d ago
0.0(0)
flashcards
Grade 10 plant biology
74
Updated 1059d ago
0.0(0)
flashcards
Exam Three Flashcards
87
Updated 737d ago
0.0(0)
flashcards
Anatomy Quiz 2
29
Updated 211d ago
0.0(0)
flashcards
AP gov
152
Updated 1172d ago
0.0(0)
flashcards
Cells Structure
30
Updated 1234d ago
0.0(0)
flashcards
Islam Glossary
41
Updated 160d ago
0.0(0)
flashcards
FDNT 151 test 1
80
Updated 1150d ago
0.0(0)
flashcards
Grade 10 plant biology
74
Updated 1059d ago
0.0(0)
flashcards
Exam Three Flashcards
87
Updated 737d ago
0.0(0)
flashcards
Anatomy Quiz 2
29
Updated 211d ago
0.0(0)