CHAP 12 COSC 1010

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

1/7

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

8 Terms

1
New cards

recursive function

a function that calls itself, usually involves if-else to control number of times it repeats

2
New cards

depth of recursion

the number of times a function
calls itself

3
New cards

problem solve with recursion

powerful tool when solving repetitive problems, can be solved with a loop, less efficient overall

4
New cards

base case

can be solved without recursion (if start index> end index return 0)

5
New cards

recursive case

reduce problem to smaller problem of the
same structure and call the function again to solve the
smaller problem (return current_number + sum(list, start+1, end))

6
New cards

calculate factorial of number with recursion

n=0 is base case, n>0 is recursive case (factorial(n)=n*factorial(n-1))

def factorial(num):, if num == 0:, return 1, else:, return num*factorial(num-1)

7
New cards

direct recursion

when a function directly calls itself

8
New cards

indirect recursion

when function A calls function B,
which in turn calls function A